The one concept that always eludes me. What is the link between sessions and cookies? When I close my browser I lose my session id. But the session object sticks around. And when my session Id is gone so is my cookie? what happens to my cookie?
Unless it expired, nothing happened to your cookie. If your session is still good on the server and you go back, the cookie will be used to access that existing session. If the session has timed out on the server and you go back with that cookie, you will get a new session and a cookie with a new session id
Originally posted by praveen oruganti: What is the diff b/w cookie ans session.
Rough Summary: A cookie is tiny text file stored in the client browser. A session is an object on the server that can store information. Either one can be utilized to track user activity, preferences and what not. Other than that, there is not much in common.
The default way of tracking sessions is via a cookie that contains a long number designed to be unique that maps to the session on the server. So when your browser makes a request, it sends the cookie to the server and the server looks up the session associated with that ID and thus it can run "the program" with variables in a state just for your current condition in running the web application.......
Cookies can be used to store other pieces of data. I have the misfortune of using cookies with Perl programming in the early days of the web and it is not something I would like to go back to.