Flask Session Cookie Signer

Build a Flask-compatible signed session cookie from JSON and a SECRET_KEY. Defaults match Flask's SecureCookieSessionInterface, and advanced fields cover custom salts, digest algorithms, key derivation, secret byte encodings, reproducible timestamps, and compression.

Try:
Signed cookie details

About this tool

Flask's default session cookie is signed, not encrypted: the browser can hold the session data, and Flask verifies an HMAC signature before trusting it. This tool builds a compatible value from a JSON object payload and your Flask SECRET_KEY using the same pieces Flask wires into itsdangerous.URLSafeTimedSerializer by default: salt cookie-session, hmac key derivation, SHA-1, compact sorted JSON, and zlib compression only when it makes the payload smaller.

Use it when you need a reproducible cookie for a local test app, a CTF lab, or a migration check. Set timestamp to a fixed Unix time when you want byte-for-byte repeatable output; leave it at 0 to sign with the current clock in the running surface. The result includes the full cookie value, a ready-to-paste Set-Cookie header, each signed segment, the serialized payload, the derived signing key in hex, and cookie-size warnings.

Worked example

Payload:

{"user":1,"admin":true}

Secret: dev-key-123, timestamp: 1700000000, Flask defaults. The output JSON contains a cookie field shaped like:

eyJhZG1pbiI6dHJ1ZSwidXNlciI6MX0.ZVPxAA.<signature>

Copy the cookie value into the session cookie, or use the set_cookie_header field in a local response. If your app uses a different salt, digest, key derivation, cookie name, or byte-encoded secret, set the matching advanced field before signing.

Limits and edge cases

FAQ

Is a Flask session cookie encrypted?

No. Flask's default client-side session is signed for integrity, not encrypted for secrecy. Anyone with the cookie can base64-decode the payload, but only someone with the correct SECRET_KEY can create a signature Flask accepts.

Which settings match Flask defaults?

Use salt cookie-session, digest sha1, key derivation hmac, compression auto, cookie name session, and a UTF-8 secret. Those defaults match SecureCookieSessionInterface for ordinary Flask apps.

Why should I set a timestamp?

The timestamp is part of the signed value. If you leave timestamp at 0, the current clock is used and the cookie changes every run. Set a Unix timestamp when you need a deterministic value for tests or documentation.

What is legacy epoch mode?

Older itsdangerous releases encoded timestamps as seconds since 2011-01-01. Current itsdangerous signs the full Unix timestamp. Enable legacy epoch mode only when you need compatibility with an old application or old challenge material.

Can this recover or crack a secret key?

No. The tool signs with a secret you already know. Secret recovery is a long-running brute-force workflow over candidate keys, which is outside this single-shot browser-safe tool model.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool flask-session-sign '{"user":1,"admin":true}' 'secret=dev-key-123'

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/flask-session-sign/?payload=%7B%22user%22%3A1%2C%22admin%22%3Atrue%7D&secret=dev-key-123&salt=cookie-session&secret_encoding=utf8&digest=sha1&key_derivation=hmac&timestamp=1700000000&legacy_epoch=true&compress=auto&cookie_name=session

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.