๐ŸŒ
Degoogle
kirsle.net โ€บ wizards โ€บ flask-session.cgi
Flask Session Cookie Decoder
Decode a Flask Session Cookie You can paste in your Flask session cookie here to decode it. Don't know how to get your cookie?
๐ŸŒ
URL Decode
urldecoder.org โ€บ dec โ€บ cookie
URL Decoding of "cookie" - Online
Decode cookie from URL-encoded format with various advanced options. Our site has an easy to use online tool to convert your data.
Discussions

[Express][Nodejs] How to decrypt express-session cookie during socket.io connection?
You can read about sharing session between express and socket.io here: stackoverflow.com/a/25618636/3902453. Also if you don't want to use that middleware. You can read about JWT ... I already have a signed cookie value. I just want to decode it so I can match it with a stored database. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Are there any tools to help decode cookies into login information?
It sounds like what you're trying to do is turn a cookie into credentials for an application. This isn't necessarily possible to do. It's poor practice for there to be a relationship between the contents of a session cookie and a user's password, although that doesn't mean it doesn't happen. Ideally, a user would supply the application with their credentials and the application would respond with a session token (often this value is stored in a cookie). This session token can be totally random data, so long as there's a record kept on the server side that this token maps to the given user. If the token does contain useful data, this will often be Base64 encoded, so if the value is mostly alphanumeric, try decoding that with a tool like https://www.base64decode.org/ If it comes out as junk, it may be encrypted, in which case you'll need some specialist knowledge on how to attack encrypted tokens are are unlikely to extract the values without the key stored on the server. It may also actually be junk, which is the safest approach to take when giving a user a session token. More on reddit.com
๐ŸŒ r/netsecstudents
2
7
June 6, 2016
Decode appSession cookie
I am attempting to create a provider using the Vercel Flags SDK. They provide a hook to identify the user and it is supplied the Headers and Cookies from the request but not the actual Request/Response objects. Normally I would use getSession(req, res) but this is unavailable to me. More on community.auth0.com
๐ŸŒ community.auth0.com
2
0
January 21, 2025
node.js - How to decode express-session cookies? - Stack Overflow
I isolated the problem, as far as I could, but still cannot solve it. I created an empty server with loopback, added express-session and body-parser middlewares "session": { "express-session... More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 23, 2017
๐ŸŒ
Quora
quora.com โ€บ Is-it-possible-to-decode-a-session-cookie
Is it possible to decode a session cookie? - Quora
Tools: jwt.io, openssl base64 -d, online/base64 decoders, or browser devtools. ... You can read the header and payload. Validation requires the key (HMAC secret or RSA public/private pair). For RS256, public key verifies signature but cannot forge it without private key. ... Without the key you cannot decrypt. ... Use the application (authenticated endpoints) or server logs/database to resolve the token. Local testing: stolen cookie presented to the app will reveal the session...
๐ŸŒ
Base64Encode.org
base64encode.org โ€บ enc โ€บ cookies
Base64 Encoding of "cookies" - Online
Meet Base64 Decode and Encode, a simple online tool that does exactly what it says: decodes from Base64 encoding as well as encodes into it quickly and easily.
๐ŸŒ
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%
๐ŸŒ
Scrapfly
scrapfly.io โ€บ web-scraping-tools โ€บ cookie-parser
Cookie Header Parser - Parse & Decode HTTP Cookies
This tool parses Cookie request headers and Set-Cookie response headers, showing each cookie with its value, attributes, and decoded version. Essential for understanding session management in web scraping.
๐ŸŒ
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
Top answer
1 of 1
3

For your case, first of all, you need to know that the session id is generated by a generating function - generateSessionId(by default). This means the session id(sid cookie) DOES NOT contain any user data, the user data stored on the server-side(MemoryStore by default). So you should get the user session data from the server-side rather than get them from the sid cookie.

The operations like:

req.session.userId = userId;
req.session.name = name;

The userId and name will be stored in MemoryStore on the server-side.

Now, let's get the session data. The value of socket.request.headers.cookie will be a string like this:

sid=s%3AfWB6_hhm39Z7gDKvAYFjwP885iR2NgIY.uT80CXyOKU%2Fa%2FxVSt4MnqylJJ2LAFb%2B770BItu%2FpFxk; io=msngndIn0v4pYk7DAAAU
  1. we should use cookie.parse(str, options) method to parse string to a JavaScript plain object.
{
  sid: 's:fWB6_hhm39Z7gDKvAYFjwP885iR2NgIY.uT80CXyOKU/a/xVSt4MnqylJJ2LAFb+770BItu/pFxk',
  io: 'eeOnxhDIiPSE_0gfAAAm'
}
  1. We should unsign the signed cookie use cookieParser.signedCookie(str, secret) method. Get the unsigned sid:
fWB6_hhm39Z7gDKvAYFjwP885iR2NgIY
  1. Since the default server-side session storage is MemoryStore, you need to initialize it explicitly and call store.get(sid, callback) in the WebSocket connection callback function to get the user session data by sid.

The complete working example:

const session = require('express-session');
const app = require('express')();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const cookie = require('cookie');

const Allusers = [{ id: 1, name: 'Admin', username: 'admin', password: 'admin' }];
const MemoryStore = new session.MemoryStore();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(
  session({
    store: MemoryStore,
    name: 'sid',
    resave: false,
    saveUninitialized: false,
    secret: 'secretCode!',

    cookie: {
      httpOnly: false,
      maxAge: 1000 * 60 * 60 * 24 * 30,
      sameSite: true,
    },
  }),
);

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html');
});

app.post('/login', (req, res) => {
  const { username, password } = req.body;
  console.log(username, password);
  if (username && password) {
    const user = Allusers.find((user) => user.username === username && user.password === password);
    console.log(user);
    if (user) {
      req.session.userId = user.id;
      req.session.name = user.name;
      return res.redirect('/');
    }
  }
  res.redirect('/login');
});

io.on('connection', (socket) => {
  console.log('a user connected');
  const cookieString = socket.request.headers.cookie;
  console.log('cookieString:', cookieString);
  if (cookieString) {
    const cookieParsed = cookie.parse(cookieString);
    console.log('cookieParsed:', cookieParsed);
    if (cookieParsed.sid) {
      const sidParsed = cookieParser.signedCookie(cookieParsed.sid, 'secretCode!');
      console.log(sidParsed);
      MemoryStore.get(sidParsed, (err, session) => {
        if (err) throw err;
        console.log('user session data:', JSON.stringify(session));
        const { userId, name } = session;
        console.log('userId: ', userId);
        console.log('name: ', name);
      });
    }
  }
});

http.listen(3000, () => {
  console.log('listening on *:3000');
});

You will get the session data userId and name like this:

user session data: {"cookie":{"originalMaxAge":2592000000,"expires":"2021-02-14T08:31:50.959Z","httpOnly":false,"path":"/","sameSite":true},"userId":1,"name":"Admin"}
userId:  1
name:  Admin

source code: https://github.com/mrdulin/expressjs-research/tree/master/src/stackoverflow/62407074

Find elsewhere
๐ŸŒ
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))
๐ŸŒ
Bitcrowd
bitcrowd.dev โ€บ decoding-phoenix-session-cookies
Decoding Phoenix Session Cookies | bitcrowd blog
October 2, 2019 - We see that get/3 decodes the cookie differently based on whether the cookie is encrypted (an encryption_salt is present) or not. The default are signed-only cookies, which means cookies are signed and, thus, safe against external modifications but are open to be read by anyone obtaining the cookie.
๐ŸŒ
Cookiedecoder
cookiedecoder.top
Cookie Decoder & Encoder โ€“ Decode, Parse & Analyze HTTP Cookies Online Free
Automatically detects known cookies ... Decode URL-Encoded JSON Parser Known Cookies Free ยท Client-Side ... The Cookie Decoder is a free online tool that parses and decodes HTTP cookie strings instantly....
๐ŸŒ
Auth0
community.auth0.com โ€บ get help
Decode appSession cookie - Auth0 Community
January 21, 2025 - I am attempting to create a provider using the Vercel Flags SDK. They provide a hook to identify the user and it is supplied the Headers and Cookies from the request but not the actual Request/Response objects. Normally I would use getSession(req, res) but this is unavailable to me.
๐ŸŒ
Hashnode
codreline.hashnode.dev โ€บ decoding-authentication
Decoding Web Authentication: Understanding JWT, ...
February 5, 2024 - secure (optional, default: false): When set to true, the cookie will only be sent over HTTPS connections. It's recommended to set this to true in a production environment with HTTPS. At the time of logout we destroy the session using req.session.destroy() and with that we can also delete the session id from the database.
๐ŸŒ
DECODE
decodeproject.eu โ€บ cookies.html
Cookies | DECODE
May 24, 2018 - Persistent cookies remain on a visitorโ€™s device for a set amount of time. This means for example that we can identify when a site visitor is a repeat visitor or new to us. Session cookies are created temporarily and last for as long as your browser window is open, being automatically deleted ...