DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for How to set cookie using ExpressJS response.
Akshay Galande
Akshay Galande

Posted on

How to set cookie using ExpressJS response.

What is cookie?

Cookies is simple key value pair stored by web server on clients browser to store/maintain user’s state.

How it is different from Localstorage?

Locastorage can also be used to store user’s state, but cookies has more advanced configurations like β€” expiration time, same site, secure flag, Httponly, etc. By using these advanced configurations we can programatically manage user’s state. It is considered that cookies are more secure than Localstorage in terms of handling user session or secret values like authentication tokens.

What is Httponly cookie?

A Httponly cookie is a simple cookie which is set by server with httponly flag as true which cannot be accessed by client side javascript.

Example

If you want to learn more, reach out to me at β€” https://twitter.com/akshay_nocode

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.