Cookies vs Sessions vs Tokens

Amar Balu
The Fresh Writes
Published in
5 min readSep 27, 2020

--

Are you new to web-development, feeling confused with different Web Storage elements?

If yes, then you are at the right place This article will give you a brief explanation about sessions, cookies and tokens using its authentication techniques.

There are two different authentication techniques namely

  • Cookie/Session-based Authentication
  • Token-based authentication

What are cookies and sessions?

In simple words, Cookies and Sessions are files used to store information.

How do they differ

  • Cookies are text files stored only on the client-side machine, where sessions create a file in a temporary directory on the server to store variables. Variables inside sessions help us to track user activities.
  • Cookies get stored in the browser where sessions are not.
  • Cookies can keep the information until it gets deleted where sessions get destroyed whenever the user tries to close a browser. Sessions will end by the server over a predetermined period, commonly 30 minutes duration.
  • Variables defined inside a cookie helps the user from providing credentials for authentication every time. Variables inside a session help to track…

--

--

Amar Balu
The Fresh Writes

I'm a front-end developer. I love React and Redux, Java, and Data Science. I write code for fun!. Join our publication : https://medium.com/thefreshwrites