Whenever we open any website on any Internet Browser, we come across the following series of Status Messages on the status bar. For e.g. Connecting to.., Website Found Waiting for Reply, Downloading.., and finally “Done”. But after the initial page has loaded if we were to click on any Hyperlink we find that we get the same series of messages again. If we get the same message again it means that after the Initial connection was made, the Server has snapped its connection with the Client.
Why Does the Server Disconnect from the Client? The answer to this is that Internet Connections make use of the HTTP Protocol which is stateless in nature. If the Server maintains a dedicated connection line with the Client, there is no guarantee that the Client will actually use the connection to an optimum. Hence, the Server snaps the connection so that it can connect with so many other clients at the same time (if the earlier Client wants to access some resource all it has to is – Reconnect).
In the Initial connection attempt, the Client would need to pass all its technical information like IP address, Port number, OS , Browser Version etc to the Server. But for every Reconnection if the Client were to do that, it would waste considerable time on the Internet. Hence, there is a need of ‘Internet Cookies’. When the Server is about to make a response for any request made by the Client, it simply stores the last ‘transaction’ state of the client onto a Cookie and sets it on the Client Terminal itself during Response. Cookies store or maintain the state of the Client as it connects the Server and stores it on the Client Side itself in the folder ‘Temporary Internet Files’.
The advantage of using Cookies is that for every Reconnection, the Client may not ‘Re-introduce’ itself again and again. The Server just picks up wanted information from the Cookie (stored in an expected format) and establishes the Response. Cookies can also store repeated ‘user-entry’ information like ‘Remember Password’ facility that is found in most of the user logins today. However, if we want to, we can erase all Cookies on the Client Side by simply selecting ‘Delete Cookies’ or clearing ‘Temporary Internet Files’ folder from the Browser > Internet Options Menu.
A 2 point golden rule about Cookies is:
• Cookies are “Set” by Server on Client during ‘Response’.
• Cookies are “Retrieved” by Server from Client during ‘Request’.
So, Internet Cookies serve the purpose of increasing the overall Request to Response Efficiency and reduce time lag. It is to be noted that programmatically it is possible for the Web Developer to set an Expiry Date and time on the Internet Cookie so that it automatically terminates or destroys itself on the Client side after some limited usage. In Server Side Scripting Languages like ASP there are methods like ‘Expires’ which can be used for the purpose. Cookies set by one Server can also later on be accessed by another Server, which is a useful e-marketing tool these days.