What are Cookies? and How they work?

What are Cookies and they works

What are Cookies? and How they work?

Cookies are the way to maintain session tracking adopted by ASP. It can store information on the client’s computer that can be sent to the server later in the same session or in future browsing sessions. Cookies can be used in a shopping application of super bazaar. Shopping Cart is a popular example. In Shopping cart, the visitor of a super bazaar adds items to the shopping cart(trolley), can remove the items from the cart and finally can make a bill. At the visitor’s click, the application should display the items he selected so far.

Cookies are small files that are sent by an Active Server Page (Cookies are adopted by many technologies like PERLCGI and Java Servlets etc.) as part of a response to a client. Every HTTP-based interaction between a client and a server includes a header that contains information about the request (when the communication is from the client to the server) or information about the response (when the communication is from the server to the client). When an Active Server Page receives a request, the header includes information such as the request type (e.g., GET or POST, time of request ctc.), and cookies stored on the client machine by the server.

Depending on the maximum age of a cookie, the Web browser either maintains the cookie for the duration of the browsing session (i.e., until the user closes the Web browser) or stores the cookies on the client computer for future use.

When the browser makes a request of a server, cookies previously sent to the client by that server are returned to the server (if they have not expired) as part of the request formulated by the browser. Cookies are automatically deleted when they expire (i.c. reach their maximum age).

What are Cookies and they works

Fields of Cookies

Cookies comprise the following five fields,


This field specifies the source of cookie. It is the responsibility of the browser to verify that the domain provided by the ner is authentic. Every individual domain can store a maximum of 20 cookies in each client.


This field specifies the path within the directory structure of the server. The path identifies the parts of the server file which can be used by the cookies. Basically, it is represented ‘/’, which implies that the entire file tree can be used by the cookie.


This field acts as a storage location for storing the content of cookies. The field is represented as: “name = value” pair.


This field specifics the time and date at which the cookies expire. If this field does not exist then such a cookie is referred 10 as a non-persistent cookie, which is automatically discarded by the browser when it terminates. On the other hand, the cookie for which the information about time and date is specified is referred to as a persistent cookie, which exists until its corresponding time expires.


This field specifies that a browser is responsible for returning the cookie to a secure server.

If you have any doubt’s on how cookies work, please let us know.