• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does cookie sent both in request and response

 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi

can anybody tell me the cookie concept in detail
how it works

suppose user send the parameter to server in html form
i want to asked , does at this moment cookie has been send
or cookie will send at the time of response

does it make some sense what i am asking
please tell the cookie concept

 
Rajesh Vijaya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cookies hold the session information between the server and the client so that the server can recongnise the client when it makes a request again.

As per your question ....

1.the first time u send the request from a client to server, there is no cookie sent from the client to the server .
2.When the server first receives the request from a particular client ,it creats the cookie and sent to the client.So in this case response sends the cookie..
3.When the client agains request the server...it sends the cookie already sent by the server along with the request for an identification....
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just want to expand on some possible unclear information...

A cookie is a just small piece of data exchanged between the client and server that includes a name/value pair, such as jsessionid=xxxxxxx. Also included in that data is a range or URLs that that cookie applies to. Every time a client sends a request to a server, it includes in the request all cookies that apply to the request's URL.

When the server recieves a request, and there is a getSession() call somewhere in the server code, it will look for a session ID first inthe cookies and then in the URL (in the case of URL rewriting). If it does not find any, it will create a new session, and set a new cookie in the response back to the client.

Although the most common use to to help maintain session state, that is not the only use. Cookies can also be used to store login information, last page visited information, or any other type of data... By default a cookie only exists for the life of a session, but you can also make them persist on the client machine for a predetermined amount of time.

hth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic