File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Cookies and session tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cookies and session tracking" Watch "Cookies and session tracking" New topic

Cookies and session tracking

Raj Jindal
Ranch Hand

Joined: Jan 17, 2003
Posts: 50
Do cookies keeps track of the session ?
They help in keeping track of the session information ?
Paul Kelcey
Ranch Hand

Joined: Jan 26, 2003
Posts: 45
I'm no expert but I understand that modern web-containers automatically handle session tracking for you using either cookies or URL rewriting. I think it depends on the client. If the client accepts cookies, then the web-container uses cookies, otherwise it uses URL rewriting.
As a developer you don't really need to be too concerned about how the web-container does it. The web-container provides a HttpSession object for you to use to store information for a particular user. I think this is what you're talking about when you say "session information"?
The web-container knows what HttpSession object to associate with a request using either one of these session tracking methods. You just need to use the HttpSession object to store and retrieve information when you're processing a request.
The typical example is a shopping cart. You would just use the HttpSession object to store shopping items in it. When they wanted to check out, you'd retrieve all of the shopping items from the HttpSession object.
It wasn't always this way however and previously you had to do it yourself. Nowadays however the web-container will take care of it for you.
I agree. Here's the link:
subject: Cookies and session tracking
It's not a secret anymore!