Each time you visit that website thereafter, your browser sends back the cookie to the server. Cookies are used by a web server to distinguish between users and maintain data related to the user.
The mechanism of cookies works as follows:
- When you type in the domain, you make a request upon the server that is hosting the site.
- The server then sends you the web page, which corresponds to the request made by you.
- The response contains a cookie, which stays on your hard drive.
- Most cookies generally contain parameters like name of the cookie, value of the cookie, and its expiration date.
Types of Cookies
They are temporary. They are removed when you close the browser. In your next visit to that site you will be treated as a new visitor. In case of a session cookie, there is nothing by way of which a browser can let know the website about your prior visits to it.
They are stored on your hard drive till you remove them or till they expire.
First Party cookies
When the website you are visiting, issues you a cookie, it is a first party cookie.
Third Party cookies
Imagine that the website you visit is hosting some advertisements. The advertisement site may also issue a cookie to you. This cookie will be called a third party cookie.
Use in Advertising
Cookies are of use in Internet advertising. Advertisers can obtain information about the on-site behavior of visitors with the help of cookies. The personal information of the visitor is anonymous but his or her web surfing habits are recorded and can be tracked by way of cookies.
A website can actually promote specific products to the visitors based on the information gathered from cookies, about the advertisements they click on. Cookies help the host server determine which banner advertisements you have seen. They can convey this information to their advertisers.
E-commerce sites implement the idea of shopping carts by utilizing the concept of cookies. The cookie contains an ID and enables the site to keep track of the things you add to your cart. When you add an item to your shopping cart, it is stored along with your ID in the database of the site. The site knows what's in your cart, when you check out.
Cookies and Session Management
Working of the HTTP protocol is of a stateless nature, which means it is not possible for an HTTP web server to differentiate one user request from another. It becomes very important for a developer to achieve session management.
Session ids associated with cookies play a vital role in uniquely identifying client requests. Session stores the information pertinent to a particular user for the duration of his visit.
Cookies help you get rid of repeatedly following certain procedures on the site, like form filling or signing in. Once you are a registered user, you may not have to perform the process of signing in each time you visit the site.
Once you have filled forms, the information filled can be remembered by means of cookies. Shopping websites can base their purchase recommendations on the information supplied by you.
It is not really true that cookies compromise your security. But, yes, they affect your privacy. Cookies are not executable programs, which can harm your computer. They are literally plain text. Regrettably, there are some cookies that store personal information.
A cookie can identify the computer and the software you are using. A dishonest site can make available, your information to the outsiders. So, if you do not want to be monitored by websites, it is best to delete cookies on a regular basis.