Search This Blog

Tuesday, 1 November 2011

Managing Client information with Cookies

0 comments
  COOKIES IN ASP! 
Cookies are bits of information saved on a client computer for later use of the Web Server in the same browsing or in the future browsing session. For e.g., cookies could be used in a shopping application to keep track of the client’s shopping cart items.
Cookies are small files sent by an ASP as part of a response to a client. Every HTTP-based interaction between a client and a server includes a header that contains the information about the request or the response. When an ASP receives a request, the header includes the request type (e.g., post or get) and cookies stored on the client machine by the server. When the server formulates its response, the header information includes any cookies the server wants to store on the client computer.
Cookies are stored and retrieved from the client’s machine using Response and Request objects of the server ASP. The Cookies collection of the Request object is used to retrieve the values of the cookies sent in the HTTP request and the cookies collection of the Response object is used to set the value of a cookie.
The life time of a cookie is determined by its creator, the developer of the web site. When the specified time is over, the cookie deletes itself from the client. Depending on the maximum age of a cookie, the web browser either maintains the cookie for the duration of the browser session (i.e., until the user closes the web browser) or stores the cookie on the client computer for future use.
Some clients do not allow cookies to be written on their machine. A refusal to accept cookies may prevent the client from being able to use the web site that attempted to write the cookie. The following is an example for storing and retrieving from the client machine by a server:

Program: Client.html that gets input form the User to be stored in  Cookies


Program: Cookies.asp that stores and retries Cookies from the Client



To know more about ASP mail me @
davidjlivingston@gmail.com 

Note:  Articles relevant to ASP may be found by following the links provided in the sidebar.

Leave a Reply