Express.js req.signedCookies Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Request

Definition

In Express.js, req.signedCookies is an object of signed cookies that cookie-parser has verified with your secret. Values are unsigned and ready to use. If none are present, it defaults to {}.

Express keeps signed values here (not in req.cookies) so you do not mix easy-to-spoof plain cookies with verified ones. Set them with res.cookie(name, value, { signed: true }).

Syntax

Read req.signedCookies in your Express.js route handler. Start with this line.

Express
app.use(cookieParser('your-secret'))
req.signedCookies           // Object (default {})
req.signedCookies.user      // verified value, or undefined / false
CallWhat it does
app.use(cookieParser('your-secret'))Primary signature.
req.signedCookies // Object (default {})Related call form.
req.signedCookies.user // verified value, or undefined / falseRelated call form.

Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.

Library declarations
Express
const express = require("express");
const app = express();

app.use(cookieParser('your-secret'))
req.signedCookies           // Object (default {})
req.signedCookies.user      // verified value, or undefined / false

Parameters

This Express.js property is read from the request or response — it has no call parameters.

Return Value

req.signedCookies is an object of cookies that passed signature verification (via cookie-parser with a secret). Tampered values appear as false.

Express
app.use(cookieParser('keyboard cat'));
const session = req.signedCookies.session;
if (session === false) { /* tampered */ }

Express.js Examples

Example 1 — Set and Read a Signed Cookie

Mount cookie-parser with a secret, set { signed: true }, then read req.signedCookies.

Express
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();

app.use(cookieParser('demo-secret'));

app.get('/login', (req, res) => {
  res.cookie('user', 'tobi', { signed: true, httpOnly: true });
  res.send('Signed cookie set');
});

app.get('/profile', (req, res) => {
  const user = req.signedCookies.user;
  if (!user) return res.status(401).send('No valid signed cookie');
  res.send('Hello, ' + user);
});

app.listen(3000);

How It Works

  1. Secret on the parser. cookieParser('demo-secret') enables signing and verification.
  2. Set signed. { signed: true } stores a value prefixed with s: plus a signature.
  3. Read verified. On /profile, req.signedCookies.user is the plain value 'tobi'.
  4. Guard missing. If the cookie is absent or invalid, treat it as unauthenticated.

Example 2 — Plain Cookie vs Signed Cookie

Show why Express separates the two objects.

Express
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();

app.use(cookieParser('demo-secret'));

app.get('/set', (req, res) => {
  res.cookie('theme', 'dark');                      // plain
  res.cookie('userId', '42', { signed: true });     // signed
  res.send('Cookies set');
});

app.get('/debug', (req, res) => {
  res.json({
    cookies: req.cookies,
    signedCookies: req.signedCookies
  });
});

app.listen(3000);

How It Works

  1. Two Set-Cookie calls. One unsigned, one with signed: true.
  2. Parser splits them. Valid signed cookies are moved into req.signedCookies.
  3. Plain stays in req.cookies. theme is easy to forge — do not treat it as proof of identity.
  4. Intent is clear. Reading from signedCookies signals “this value was verified.”

Example 3 — Detect a Tampered Signed Cookie

Failed signatures become false — reject them explicitly.

Express
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();

app.use(cookieParser('demo-secret'));

app.get('/account', (req, res) => {
  const user = req.signedCookies.user;

  if (user === false) {
    res.clearCookie('user');
    return res.status(400).send('Tampered signed cookie');
  }
  if (!user) {
    return res.status(401).send('Missing signed cookie');
  }

  res.send('Account for ' + user);
});

app.listen(3000);

How It Works

  1. Parser verifies. Bad signatures do not yield the forged string — they yield false.
  2. Check false first. Distinguishes “tampered” from “missing” (undefined).
  3. Clear bad cookies. res.clearCookie drops the bad value from the client.
  4. Only trust real values. Proceed when you have a non-empty, non-false string.

Runtime Support

req.signedCookies is populated by the cookie-parser middleware on an Express.js server (Express 5 needs Node.js 18+). Browsers only store and send the Cookie header.

✓ Server · Express 4 & 5

req.signedCookies

Works wherever Express and cookie-parser run: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not a browser API.

Server Node.js runtime API
Node.js 18+ for Express 5 · 14+ typical for Express 4
Supported
Bun Express-compatible server apps
Supported
Deno Via npm compatibility / adapters
Supported
req.signedCookies Express + cookie-parser

Bottom line: Install cookie-parser, pass a secret, and run examples with Node.js and the express package.

Frequently Asked Questions

It is an object of signed cookies that cookie-parser has verified with your secret. Values are unsigned and ready to use. It defaults to {} when none are present.
Yes. Mount cookie-parser with a secret, for example app.use(cookieParser('my-secret')). Without a secret, signed cookies are not parsed into this object.
req.cookies holds unsigned (plain) cookies. Valid signed cookies are moved into req.signedCookies so you do not confuse easy-to-spoof values with verified ones.
Signature validation fails. cookie-parser sets that cookie’s value to false in req.signedCookies instead of the tampered string.
No. Express documents that signing prevents tampering; it does not hide or encrypt the value. Anyone can still read the cookie contents.

Next: req.stale

See when a request is considered stale for caching.

req.stale tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful