Thursday, March 19, 2020

Cookies vs Sessions


Cookies are textual information created by server and stored on client machine only. Cookie can only be read from the domain that it has been issued from. For example, a cookie set using the domain www.guru99.com cannot be read from the domain career.guru99.com.
Most websites are having option to disable cookies, third party cookies or both. 
Cookies Ex: Page visited information, User preferences, remembering username and password.

Sessionsessions get stored on the client as well as a server. A session creates a file in a temporary directory on the server where registered session variables and their values are stored. This data will be available to all pages on the site during that visit.
Whenever a session is created, a cookie containing the unique session id is stored on the user’s computer and sends the session id with every request to the server.
If the client browser does not support cookies, the unique session id is displayed in the URL.The session values are automatically deleted when the browser is closed.

Key Differences:
  • Cookies are client-side files that contain user information, whereas Sessions are server-side files that contain user information.
  • Cookie is not dependent on session, but Session is dependent on Cookie.
  • Cookie expires depending on the lifetime you set for it, while a Session ends when a user closes his/her browser.



No comments:

Post a Comment

JMeter Simple Controller

  Simple Controller is just a  container  for user request.