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

what is a cookie in java ?

siva chaitanya
Ranch Hand

Joined: Jul 05, 2011
Posts: 59
Please explain me with an example i am searching on google but i cant able to get the right answer.
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi ,

Refer this Thread.

siva chaitanya
Ranch Hand

Joined: Jul 05, 2011
Posts: 59
Thank you for the reply but cookie and session both are used to store information apart cookie is stored at client side whereas session is stored at server side but my question is what information we store in cookie and what information we store in session?
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

Typically the server-side session is used to store the state of user interactions on a website, for example shopping cart data. The server-side session is identified by a unique id (JSESSIONID), which is typically stored in a client-side session cookie. Unless the browser doesn't support cookies, in which case it ends up the URL. There are many other uses for client-side cookies though, but session tracking is one of the most common.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

For your better understanding, Say if you are logging into a mail account , Once you provide the username and password the data will reach the mail server as a response it sends an information like identification of your IP, date time so on all these will be stored in the cookie with the Unique id given to you. this (cookie file) can be viewed in your system too.

on other part session is like say after you logged in you might see your username across different pages like inbox, sent items, trash so on here your username will maintained by the session until you sign out This is called session

Hope you understood now.
I agree. Here's the link:
subject: what is a cookie in java ?
It's not a secret anymore!