Easy way to get 15 free YouTube views, likes and subscribers
Get Free YouTube Subscribers, Views and Likes

Difference between cookies session and tokens

Follow
Valentin Despa

What are cookies, sessions, and tokens? Most web servers use cookies to send the sessionID after you log in.
Click on SHOW MORE

So the server will store the session information in the database while you will only have the session id in a cookie, which is stored in the filesystem of your computer.

Next time you request another page, your browser will automatically send a cookie containing your sessionId, which the server will check to see if it is valid.

The sessionID is randomly generated and should be hard to guess. If you log out, the session will be deleted on the server, but also the server will instruct the browser to delete the cookie containing the sessionID.

An alternative to this is to store information on the client and sign it. In this scenario, anyone holding the signature can quickly check if the data was manipulated or not. One way to do this is to use JSON Web Tokens (JWT tokens).

Let's now assume that you want to install an app on your phone, which can help you with your finances and keep track of your spendings. What you don't want to do is to give your username and password to this app, which was not created by your bank. This is when access tokens are being used to grant access to your data.

Technologies mentioned in this video:

JWT Tokens: https://jwt.io/
OAuth, OAuth2: https://oauth.net/
OpenId: https://openid.net/

#cookies #sessions #tokens


⭐ Additional explanation ⭐


[1] In the example shown, the user transitioned from a notloggedin state (one session id) to a loggedin state (new session id). This is why you see two cookies. Make sure you check the HTTP requests for the SetCookie and Cookie headers.

[2] While both the Cookie/SetCookie and Authorization are headers, a browser will always treat the Cookie/SetCookie differently.


If this was helpful and you want to support me create more videos like this one, please consider subscribing.
   / @vdespa  



⭐ Video contents ⭐

⌨ 00:00 Login example with cookies
⌨ 05:26 Recap: cookies and sessions
⌨ 06:06 Tokenbased authentication
⌨ 09:20 Difference between tokens vs session cookie
⌨ 11:00 Conclusion



⭐ I have a question. ⭐

I do my best to answer all comments here on YouTube but I cannot make any guarantees.

Please do not email me or contact me on other channels as I might not be able to answer. Sorry!



⭐ I have a video idea ⭐

Do you want me to create a video on a specific topic? Just fill out the form below:

https://forms.gle/uWEzXFQ2viJtZtvZ7



⭐ Contact & Imprint ⭐

Follow me on Twitter:
  / vdespa  

Follow me on Medium:
  / vdespa  

Follow me on Facebook:
  / valentindespa113038143438826  

Let's connect on LinkedIn:
  / vdespa  

http://vdespa.com/imprint

posted by derrikqb