Medium severity

How to fix cookies without the Secure flag

One of your cookies is set without the `Secure` attribute. This means the browser will send it over plain HTTP — readable by anyone on the same Wi-Fi network. Every cookie on an HTTPS site should have `Secure`. The fix is one attribute in your `Set-Cookie` header: `; Secure`. Update wherever your app sets cookies (auth middleware, session library, framework config).

Why it matters

Session cookies without Secure can be intercepted on public Wi-Fi and used to impersonate the user. HSTS helps but does not replace this — Secure is a defense at the cookie level.

How to check

  1. 01DevTools → Application → Cookies → check each cookie.
  2. 02The `Secure` column should be true for every cookie on an HTTPS site.
  3. 03For session/auth cookies, HttpOnly and SameSite should also be set.

Or let SafeToShip check it for you in 60 seconds:

How to fix it

Next.js cookies

When setting cookies in Route Handlers or middleware, always pass secure.

import { cookies } from 'next/headers';

const cookieStore = await cookies();
cookieStore.set({
  name: 'session',
  value: token,
  httpOnly: true,
  secure: true,
  sameSite: 'lax',
  path: '/',
  maxAge: 60 * 60 * 24 * 7,
});

Generic

Add `Secure` to every cookie.

Set-Cookie: session=abc123; Secure; HttpOnly; SameSite=Lax; Path=/

AI prompt

Copy-paste into your AI tool

Paste this prompt into Cursor, Lovable, Bolt, v0, or Claude Code and it will walk through the fix for your specific codebase.

Audit every place my app sets cookies. For each cookie, add the Secure, HttpOnly, and SameSite=Lax attributes (or SameSite=Strict for auth cookies). Explain any cookie where I need JavaScript access and cannot use HttpOnly.

FAQ

Frequently asked questions

What about localhost?
Secure cookies do work on localhost in modern browsers (Chrome 89+, Firefox 75+). If yours do not, set them conditionally based on NODE_ENV.

Scan your site for this and 50+ other issues

Free scan. Results in 60 seconds. No account required.