-3

Possible Duplicate:
Differences between cookies and sessions?

what are the difference between using cookie or session in a servlet? when is better to use cookie or session information?

Community
  • 1
  • 1
giozh
  • 8,808
  • 27
  • 89
  • 163
  • 4
    [Look](https://www.google.com/search?sourceid=chrome&ie=UTF-8&q=cookie+vs.+session), I typed less and already have an answer! But sure, wait for someone to copy-paste one of those links over here. – Marko Topolnik May 07 '12 at 18:02
  • 3
    Check the below link.Its good http://stackoverflow.com/questions/359434/cookies-vs-session – user1357722 May 07 '12 at 18:04

1 Answers1

2

Cookie is a special HTTP header that can contain several key/value pairs. The special feature of cookie is that clients (typically browsers) are able to store them. Cookies have expiration time. Cookies as all other HTTP headers are sent with HTTP request that can be accessed by servlet.

One of cookies can contain session ID.

Session is an entity that identified by session ID and can contain information about current client/server negotiation sequence. For example attributes.

I hope this helps. For more information try to read http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol, then continue reading about Java servlet API

AlexR
  • 109,181
  • 14
  • 116
  • 194
  • So i can send the session id in a cookie to client and keep on server side a structure contains the session number associated for each client? it could happen that for a new connection, this can have a session number already assigned (and saved in the structure i told)? – giozh May 07 '12 at 18:59