Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sessions and cookies

 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
praveen oruganti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the diff b/w cookie ans session.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
praveen oruganti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marc Peabody and Marcus Green
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic