I was looking at a cookie set through the session object in flask and it was just a hash (or it looked like it was just a hash). The value I set for the cookie was nowhere to be found but flask could get the value back.
I thought you had to store the value in the cookie alongside the hash (and then have a SECRET in your app to mix with the value for the hash), otherwise I don't know how you'd get your value back.
I thought maybe they hash the secret and the value and then encode it for extra obfuscation or something along those lines.
The cookie value contains compressed and serialised data.
Flask does this to the data stored in the cookie:
On reading the cookie Flask only has to:
Most of this is taken care of by itsdangerous
. The JSON encoding and decoding is handled by the Flask session
module.
Until recently, pickle
was used to do the serialisation but that has security risks if the server-side secret was ever stolen. See Better Client-side sessions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With