Issue
I am training in web developement and am learning about JSP & Servlets. I have some knowledge of HttpSession
- I have used it in some of my sample projects.
In browsers I have seen the option to "delete cookies". If I delete the cookies it deletes the HttpSession
also.
Are cookies and session the same? What are the differences between them?
Solution
Sessions are server-side files that contain user information, while Cookies are client-side files that contain user information. Sessions have a unique identifier that maps them to specific users. This identifier can be passed in the URL or saved into a session cookie.
Most modern sites use the second approach, saving the identifier in a Cookie instead of passing it in a URL (which poses a security risk). You are probably using this approach without knowing it, and by deleting the cookies you effectively erase their matching sessions as you remove the unique session identifier contained in the cookies.
Answered By - Eran Galperin
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)