Cookies
Learn Cookies (Session Management, JSP Servlets) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is a Cookie? • A cookie is a small piece of data stored in the user's browser by the server. • It helps maintain state in web applications (since HTTP is stateless). Why Cookies are Needed? • Maintain login sessions • Store user preferences (theme, language) • Track user activity • Personalization • Shopping cart management Real-Life Example • When you log in to an e-commerce website, the server stores a session cookie. • That cookie tells the server who you are on every request. How Cookies Work • User sends request to server • Server responds with Set-Cookie header • Browser stores the...