Difference between Cookies and Sessions

Key Difference: Cookie, also known as HTTP cookie, web cookie, or browser cookie, is a small packet of data that is sent from a website to the server and is stored in the user’s web-browser. The cookies are used to send information to the website creator, regarding the previous activities of the user when they last accessed the website. Sessions are semi-permanent interactive information exchange between two communicating devices, such as a user computer and a server. This is also known as a dialogue, a conversation or a meeting between two or more devices. A session is basically a communication that is set up at one point and torn down at another point.

Cookies and sessions are two types of technologies used when dealing with the World Wide Web. Cookies and sessions are used to save certain type of data, so that pages would load faster, quicker and use less amount of bandwidth. Cookies are generally stored on the client-side machine, while sessions are stored on the server-side machine. These two are different in how they behave and what they do, hence they should not be confused as the same thing.

Cookie, also known as HTTP cookie, web cookie, or browser cookie, is a small packet of data that is sent from a website to the server and is stored in the user’s web-browser. The cookies are used to send information to the website creator, regarding the previous activities of the user when they last accessed the website. These cookies were designed to allow the websites to remember the client’s actions during previous visits. When the client accesses the website a second time, the cookies are sent from the client browser to the website. Cookies save data such as clicking particular buttons, logging in, or a record of which pages were visited by the user even months or years ago. Many companies also use cookies for promotion purposes, showing ads of the type of things a user is searching for.

Although cookies cannot carry viruses or any other kinds of malware, it is quite easy to track cookies and third-party cookies to check the user’s browser history. This is considered as unlawful by the government. Cookies also can be used to save forms and passwords. Notice, when you start to type e-mail address, it automatically shows you options of e-mail addresses previously logged in. If you save the password, the cookies will also automatically save password and keep you logged in the website. There are various different types of cookies: Session cookie, Persistent cookie, Secure cookie, HttpOnly cookie, Third-party cookie, Supercookie and Zombie cookie.

Sessions are semi-permanent interactive information exchange between two communicating devices, such as a user computer and a server. This is also known as a dialogue, a conversation or a meeting between two or more devices. A session is basically a communication that is set up at one point and torn down at another point. In a session, the device sends information back and forth. Sessions are also stored on the server-computer, which means the client side computers have no access to it. In sessions, data is stored on both sides. The client-side cookie only stores a reference number of the data stored on the server.

During a session, when a client logs onto the website, the client-side cookie sends data to the server-side cookie, which then loads the data that the client has saved. For example: If a user logs onto the Macy’s website, creates a profile and adds things to their shopping cart. When the person logs in again, the profile will be how they created it and the items added to the shopping cart will still be there. This is how the session work. Sessions are usually short-term and can be torn down once a browser is cancelled. For example: if a user logs on to their gmail account and randomly keep opening pages, they will be still logged onto their account. If they cancel the browser and after some time access gmail, they would have been automatically logged out. This was because the session was ended.

Although, sessions and cookies are both ways to store information across web pages, they are different in how the information is accessed. Cookies are only stored on the client-side machine, while sessions are stored on both. Cookies are also used to save passwords and form data in the browser, so that the user does not need to log in. Cookies also considered to be less safe compared to sessions.

Image Courtesy: delete-computer-history.com, googlesystem.blogspot.com

Most Searched in Electronics Most Searched in Society and Culture
Most Searched in Pregnancy and Parenting Most Searched in Sports
TFT vs LCD
Board of Directors vs Management
Pong vs Ping Pong
Antivirus vs Firewall Software

Add new comment

Plain text

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.