Friday, March 9, 2012

What is a Cookie ?

What is a Cookie ?

A Cookies is a small piece of information thar scripts can store on a client-side machine. You can set a Cookie on a user’s machine by sending as HTTP header containing data in the following format:-

Set-Cookie: NAME=VALUE; [expires=DATE;] [path=PATH;]

[domain=DOMAIN_NAME;] [secure]

This create a cookie called NAME with the value VALUE. The other parameters are all options. The expires field sets a date beyond which the cookie is no longer relavent (Note that if no expiry date is set , the cookie is effective permanent unless you or the user manually delete it ). Together, the path and domain can be used to specify the URL or URLs for which the cookie is relevant . The secure keyword means that the cookie will not be sent over a plain HTTP connection.

When a browser connects to an URL, it first searches the cookie stored locally . If any of them are relevant to the URL being connected to , they will be transmitted back to the server .

Published By Bhupendra Chahar

No comments:

Post a Comment