posted 18 years ago
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
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook