🌐
Degoogle
kirsle.net › wizards › flask-session.cgi
Flask Session Cookie Decoder
"""Flask session cookie decoder.""" #import cgitb #cgitb.enable() import os import codecs import cgi import jinja2 from base64 import b64decode from itsdangerous import base64_decode import zlib import json import pygments from pygments.formatters import HtmlFormatter from pygments.lexers import PythonLexer, JsonLexer import uuid from werkzeug.http import parse_date from flask import Markup env = jinja2.Environment(loader=jinja2.FileSystemLoader(".")) def main(): form = get_form() # Pygments CSS source.
People also ask

Can this tool crack or forge Flask session cookies?
No. This tool only decodes the unsigned payload. It cannot brute-force the secret key or forge valid signatures. For signing and brute-forcing, use the flask-unsign CLI tool.
🌐
flask-unsign.vercel.app
flask-unsign.vercel.app
Flask Unsign - Online Flask Session Cookie Decoder & Inspector Tool
What Flask session formats are supported?
Flask Unsign supports all standard Flask/Werkzeug session cookie formats including uncompressed base64url payloads, zlib-compressed payloads, and cookies with or without timestamp/signature sections.
🌐
flask-unsign.vercel.app
flask-unsign.vercel.app
Flask Unsign - Online Flask Session Cookie Decoder & Inspector Tool
Is Flask Unsign the same as the flask-unsign Python package?
This is a browser-based alternative to the popular flask-unsign Python CLI tool. While the CLI tool can also brute-force secret keys and sign cookies, this web tool focuses on decoding and inspecting session payloads without needing Python installed.
🌐
flask-unsign.vercel.app
flask-unsign.vercel.app
Flask Unsign - Online Flask Session Cookie Decoder & Inspector Tool
🌐
GitHub
gist.github.com › babldev › 502364a3f7c9bafaa6db
Decode a Flask Session cookie, given the cookie and secret key · GitHub
Decode a Flask Session cookie, given the cookie and secret key - decode_flask_cookie.py
🌐
GitHub
github.com › ewewraw › flask-session-cookie-decoder
GitHub - ewewraw/flask-session-cookie-decoder
A Node.js module for decoding Flask session cookies, allowing you to extract and decompress the data stored within them.
Author   ewewraw
🌐
picoCTF Solutions
picoctfsolutions.com › tools › flask-session-decoder
Flask Session Cookie Decoder | picoCTF Solutions
Paste a Flask session cookie value and the tool splits it into payload / timestamp / signature, decompresses the zlib payload if Flask compressed it, parses the JSON, and - if you supply the secret key - verifies the HMAC.
🌐
Readthedocs
flask-cookie-decode.readthedocs.io › en › latest › readme.html
1 flask-cookie-decode — flask-cookie-decode 0.4.3 documentation
from flask import Flask, jsonify, session, request from flask_cookie_decode import CookieDecode app = Flask(__name__) app.config.update({'SECRET_KEY': 'jlghasdghasdhgahsdg'}) cookie = CookieDecode() cookie.init_app(app) @app.route('/') def index(): a = request.args.get('a') session['a'] = a return jsonify(dict(session))
🌐
Flask Unsign
flask-unsign.vercel.app
Flask Unsign - Online Flask Session Cookie Decoder & Inspector Tool
Flask and Werkzeug use a specific signed cookie format to store session data on the client side. This tool lets you paste any Flask session token and instantly decode the base64-encoded payload, detect zlib compression, extract embedded timestamps, and visualize the full JSON session data - all ...
🌐
GitHub
github.com › noraj › flask-session-cookie-manager
GitHub - noraj/flask-session-cookie-manager: :cookie: Flask Session Cookie Decoder/Encoder · GitHub
Flask Session Cookie Decoder/Encoder positional arguments: {encode,decode} sub-command help encode encode decode decode optional arguments: -h, --help show this help message and exit
Starred by 774 users
Forked by 93 users
Languages   Python 88.9% | Shell 11.1%
Find elsewhere
🌐
Noraj
noraj.github.io › flask-session-cookie-manager
Flask Session Cookie Decoder/Encoder | flask-session-cookie-manager
usage: flask_session_cookie_manager{2,3}.py decode [-h] [-s <string>] -c <string> optional arguments: -h, --help show this help message and exit -s <string>, --secret-key <string> Secret key -c <string>, --cookie-value <string> Session cookie value
🌐
GitHub
gist.github.com › aescalana › 7e0bc39b95baa334074707f73bc64bfe
Decode and Encode Flask's session cookie. Great for testing purposes; only the secret key is needed · GitHub
Decode and Encode Flask's session cookie. Great for testing purposes; only the secret key is needed - manageFlaskSession.py
Top answer
1 of 3
6

The cookie value is quoted by the Werkzeug library to be safe for use in Cookie headers; this includes quoting any commas, semicolons, double quotes and backslashes:

cookie_quoting_map = {
    b',' : b'\\054',
    b';' : b'\\073',
    b'"' : b'\\"',
    b'\\' : b'\\\\',
}

Anything else outside of letters, digits and the characters !#%&'~_`><@,:/$*+-.^|)(?}{= is encoded to an octal codepoint as well. If there are any escaped values in the cookie, the whole cookie is also surrounded by double quotes.

If you need access to the cookie value in JavaScript, you'll have to decode this again. Values that start with a slash and 3 digits are octal values; a String.replace() call should do:

function decode_flask_cookie(val) {
    if (val.indexOf('\\') === -1) {
        return val;  // not encoded
    }
    val = val.slice(1, -1).replace(/\\"/g, '"');
    val = val.replace(/\\(\d{3})/g, function(match, octal) { 
        return String.fromCharCode(parseInt(octal, 8));
    });
    return val.replace(/\\\\/g, '\\');
}

Demo:

> // recreate properly escaped value
> var cookie = "\"{\\\"message\\\": \\\"hello\\\"\\054 \\\"type\\\": \\\"success\\\"}\""
> cookie
""{\"message\": \"hello\"\054 \"type\": \"success\"}""
> decode_flask_cookie(cookie)
"{"message": "hello", "type": "success"}"
> JSON.parse(decode_flask_cookie(cookie))
Object {message: "hello", type: "success"}
2 of 3
0

Dealing with the same issue today, but it seems the facts on the ground have changed.

First of all, sending the cookie back is as simple as:

cookie_str = json.dumps(mydictionary, separators=(',', ':'))
resp.set_cookie('cookiename', cookie_str, None, None, '/') 

On the Javascript side, in browser, I read the cookie as follows using the js-cookies project:

var cookie2 = Cookies.noConflict();
var cookiejs = cookie2.getJSON('cookiename');
var one = ca.field1;
var two = ca.field2;

It does appear that the curly's are not getting escaped properly in my case. As a result, I have to find and replace the curley's with escaped versions \{ and \}. However, after that, instead of using getJSON, I had to resort to jquery's $.parseJSON() function, which returns a usable json object.

Still haven't figured out how to get the cookie json string to behave correctly without re-escaping the curley's on the javascript side. The escaping and jquery method is a little hacky... but it works.

Also I'm using Zappa-Flask in AWS Lambda, not sure if that is messing up my cookie.

🌐
Xin Fu
imfing.com › til › decode-flask-session-cookie
Decode Flask session cookie | Xin Fu
January 4, 2023 - Here’s a short Python snippet that decodes the session cookie using zlib and base64.urlsafe_b64decode. import zlib import base64 def decode(cookie): """Decode a Flask cookie.""" try: compressed = False payload = cookie if payload.startswith('.'): compressed = True payload = payload[1:] data = payload.split(".")[0] data = base64.urlsafe_b64decode(data) if compressed: data = zlib.decompress(data) return data.decode("utf-8") except Exception as e: return "[Decoding error: are you sure this was a Flask session cookie?
🌐
PyPI
pypi.org › project › flask-session-decoder
flask-session-decoder · PyPI
from flask_session_decoder import ... decoded string representation of the cookie. decoder.json(cookie) returns the (by default verified) decoded cookie as a dict....
      » pip install flask-session-decoder
    
Published   Dec 16, 2022
Version   0.1.0
🌐
PyPI
pypi.org › project › flask-cookie-decode
flask-cookie-decode · PyPI
Adds a cookie command to the built-in Flask CLI which will provide various tools for debugging the secure session cookie that Flask uses by default. flask cookie decode: decodes and verifies the signature of the session cookie
      » pip install flask-cookie-decode
    
Published   Mar 09, 2025
Version   0.4.3
🌐
Ari
ari.lt › tools › flaskcookie
Tools - FlaskCookie - ari.lt
Decode Python Flask session cookies online and display their detailed information.
🌐
Key Decryptor
keydecryptor.com › home › decryption tools › flask cookie decoder
Flask Session Cookie Decoder & Verifier Online
This tool implements the same three core operations: - **Decode** - read the session payload from any Flask cookie without needing the secret key - **Verify** - confirm a cookie was signed with a given secret (useful for CTFs or audits) - **Sign** - craft a new cookie from arbitrary JSON data and a known secret
🌐
DigiNinja
digi.ninja › blog › cracked_flask.php
Cracked Flask Lab - DigiNinja
December 9, 2021 - flask-unsign --decode --server https://crackedflask.digi.ninja/user ... Cracked it and got the secret key "monkey" so now create a new cookie with the username admin rather than robin: flask-unsign --sign --secret monkey --cookie "{'hello': ...
🌐
GitHub
github.com › volfpeter › flask-session-decoder
GitHub - volfpeter/flask-session-decoder: Zero-dependency Flask session decoder · GitHub
from flask_session_decoder import ... decoded string representation of the cookie. decoder.json(cookie) returns the (by default verified) decoded cookie as a dict....
Author   volfpeter
🌐
saruberoz' site
saruberoz.github.io › flask-session-cookie-decoder-slash-encoder
Flask session cookie manager – saruberoz' site
""" Flask Session Cookie Decoder/Encoder """ __author__ = 'Wilson Sumanang' # standard imports import sys import zlib from itsdangerous import base64_decode # external Imports from flask.sessions import SecureCookieSessionInterface class MockApp(object): def __init__(self, secret_key): self.secret_key = secret_key def session_cookie_encoder(secret_key, session_cookie_structure): """ Encode a Flask session cookie Example: cookie_structure = dict( gplus_id = 1285135705050360459231, email = john.doe@gmail.com, user_info = dict( full_name = john doe, ) ) session_cookie_encoder(b'development key',