• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Sessions and cookies

 
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the diff b/w cookie ans session.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marc Peabody and Marcus Green
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic