Computer scienceBackendFlaskUser-specified interactions

Flask Sessions

Theory

Decoding

Report a typo

Decoding flask session data is elementary. Most of the time, it can be done with the following simple three lines of code:

We have seen that the session cookie is encrypted into the format Cookie: session=[session-data].[Timestamp].[Cryptographic-Hash]

from itsdangerous import base64_decode
decoded_data = base64_decode("session-data")
decoded_data = decoded_data.decode("utf-8")

The session data is easy to get from browsers or any other client you use. Download the dataset below containing three different session cookies. Using the above code, build a session data decoder, apply the decoder to each data, and put each result in a new line in the area below.

The whole cookie data is given in the data set, not just the session data. You have first to extract the session data and decode it afterwards.
Write code in your IDE to process the text file and display the results below

Create a free account to access the full topic