Difference between Session and Cookies

Difference between Session and Cookies in Tabular Form

Session and Cookies Difference




The Key Difference between Session and Cookies is that Cookies are stored on the client-side machine, Whereas Session stored on the client-side as well as a server-side. Both are used to store information.

Cookies and Session difference
Cookies and Session difference

Session vs Cookies Comparison Chart

Session Cookies
Sessions are used to store the information of the user server-side. Cookies are used to store the user information on the user’s computer in form of text files.
While the user logout from a web browser or application the session is terminated. While cookies are terminated or end up on the user’s set time.
Session has a 128 MB size to store the data at one time. Cookies have a maximum of 4 KB size.
Session can store unlimited data. Cookie can store a limited amount of data.
session_start() function is used to start the session. There isn’t any function is required to start the cookie.
Session save the user’s data in encrypted form so sessions are more secure. Cookies save the user’s data in a text file so cookies are not secure.




What is Cookie?

  • Cookie is a small piece of information that stores multiple clients requests.
  • There are 2 types of cookies
    1. Non-persistent cookie: Valid for a single session
    2. Persistent cookie: Valid for multiple session

More Difference