Difference between Cookies and Sessions



  • Cookies are Client-Side files that contains user information
  • Cookies are stored in the users browser.
  • A Cookie can keep information in the user’s browser until deleted.
  • If you set variable to “Cookies” then your user will not have to log in each time enter your community.
  • Cookies can only store strings.
  • Save Cookie for future reference.
  • Cookie allowing 4kb (4096bytes).
  •  The setcookie() function must appear BEFORE the <html> tag.


  • Sessions are Server-Side files that contain user information.
  • Sessions are not able to store.
  • Sessions is that when you close your browser you also lose the session.
  • If you set the variable to “Session” then user activity will be tracked using browser sessions and your user will have to log in each time they re-opens the browser.
  • Store our objects in sessions.
  • Session couldn’t save the user data, users close their browser, they also lost the session.
  • Session holding the multiple variable in sessions
  • Session_start() function must be the very first thing in your document. Before any HTML tags.

Leave A Reply