May 15, 2009

0 Introduction to Cookies

Hidden form fields were introduced to enable programs to maintain state information about Web browsers. Hidden fields do not allow state information to be maintained in a persistent manner. That is, hidden fields can be used with a single browser session. When a user exits the browser, the information contained in hidden form field is lost forever.

Netscape developed the cookie as a means to store state-releated and other information in a persistent manner. The information stored in cookies is maintained between browsers session. Cookies survives even when the user turns off his machine unlike session.

When a user requests a page, a HTTP request is sent to the server. The request includes a header that defines several pieces of information, including the page being requested.

The server returns a HTTP response that also includes a header. The header contains information about the document being returned, including its MIM (Multipurpose Internet Mail Extension) type. These headers all contain or more fields of information in a basic format.

Field Name Information

Cookie information is shared between the client browser and a sever using fields in the HTTP headers. When the user requests a page for the first time, a cookie (or more than one cookie) can be stored in the browser by a set-cookie entry in the header of the response from the server. The set-cookie includes the information to be stored in the cookie along with several optional pieces of information including an expiry data path, and server information and if the cookie requires security.

Then, when the user requests a page in the future. if a machine cookie is found among all the stored cookies. The browser sends a cookie field to the server in a request header. The header will contain the information in that cookie.

The set-cookie and cookie fields use a syntax to transfer significant information between client and server.


Post a Comment

Blogger Themes

Powered by Blogger