IT

Difference Between Cookies and Sessions

Cookies vs Sessions

Summary: Difference Between Cookies and Sessions is that E-commerce and other Web applications often rely on cookies to identify users. A cookie is a small text file that a Web server stores on your computer. Cookie files typically contain data about you, such as your user name or viewing preferences. While You can describe Session as a server-side storage of information that stores information of the user’s interaction with the website or web application. Unlike Cookies, Sessions stored on the server side.

Difference Between Cookies and Sessions

Cookies

E-commerce and other Web applications often rely on cookies to identify users. A cookie is a small text file that a Web server stores on your computer. Cookie files typically contain data about you, such as your user name or viewing preferences. Many commercial Web sites send a cookie to your browser, and then your computer’s hard disk stores the cookie. The next time you visit the Web site, your browser retrieves the cookie from your hard disk and sends the data in the cookie to the Web site. Web sites use cookies for a variety of purposes:

  • Most Web sites that allow for personalization use cookies to track user preferences. On such sites, users may be asked to fill in a form requesting personal information, such as their name, postal code, or site preferences. A news Web site, for example, might allow users to customize their viewing preferences to display certain stock quotes or local weather forecasts. The Web site stores their preferences in a cookie on the users’ hard disks.
  • Some Web sites use cookies to store users’ passwords, so that they do not need to enter it every time they log in to the Web site.
  • Online shopping sites generally use a session cookie to keep track of items in a user’s shopping cart. This way, users can start an order during one Web session and finish it on another day in another session. Session cookies usually expire after a certain time, such as a week or a month.
  • Some Web sites use cookies to track how often users visit a site and the Web pages they visit while at the site.
  • Web sites may use cookies to target advertisements. These sites store a user’s interests and browsing habits in the cookie.
  • You can set a browser to accept cookies automatically, prompt you if you want to accept a cookie, or disable cookie use altogether. Keep in mind if you disable cookie use, you will not be able to use many of the e-commerce Web sites.

Sessions

You can describe Session as a server-side storage of information that stores information of the user’s interaction with the website or web application. Unlike Cookies, Sessions stored on the server side. While a large information which is constantly changing on the user’s side is hard to store in user’s browser, only a unique identifier is stored on the Client Side (Session ID). This session id is being sent to the server by user every time you makes an HTTP request. Sessions can’t just only store Strings, they can also store objects. But in sessions, after closing the browser user also lose their session id.

Also Read:

Difference Between Spam and Phishing

Difference Between Clickjacking and Phishing

Difference Between Social Engineering and Phishing

Difference Between Phishing and Pharming