Contents
Encrypted Cookies HTTP cookies often come from the web server so consider encrypting cookie values. This adds a layer of protection since the browser client can’t decrypt the data. This makes it so that HTTP cookies are meaningful only to the back-end application.
The best option: Block all third-party cookies. Click See All Cookies and Site Data to see a list of the cookies actually installed locally on your computer. You can go through them one by one and delete as desired. It’s not a bad idea to just do a Remove All on cookies every few months, just to clear things out.
When does a cookie have a Secure attribute?
When a cookie has the Secure attribute, the user agent will include the cookie in an HTTP request only if the request is transmitted over a secure channel (typically HTTP over Transport Layer Security (TLS)” [RFC2818]).”
Something like HMAC (username+login_timestamp, key = server_side_secret) where you essentially hash a combination of the users information with the server side secret key. Then you can associate secrets with the username and before using the secrets, verify that the session token is valid by checking the HMAC is valid.
There are 3 very important directives ( Secure, HttpOnly , and SameSite) that should be understood before using cookies, as they heavily impact how cookies are stored and secured. Cookies contain very sensitive information: if attackers can get a hold of a session ID, they can impersonate users by hijacking their sessions.
What’s the best way to secure a cookie?
Consequently, one of the best practices regarding the security of cookies is to properly manage their scopes. The last 2 attributes, secure and HttpOnly specifically deal with security. Please note that they do not require any associated value: their very presence is enough for the browser to behave as expected when it comes to the cookie.