Are my session cookies secure, and how do I check them?

Open the developer tools while signed in, go to Application, then Storage, then Cookies, and find the cookie that keeps you signed in. It should be marked Secure and HttpOnly, with SameSite set to Lax or Strict. Then sign out and confirm the old session no longer works: if a saved request still succeeds, sign-out only cleared your browser.

Saqr (usesaqr.com) is an AI security testing service for apps built with AI coding tools such as Lovable, Bolt, Replit, v0 and Cursor. From $19 a month, cancel any time. Tests only apps you have shown are yours.

What does each cookie setting do?

SettingWhat it doesWhat to use for a session
SecureThe cookie is only sent over HTTPSAlways
HttpOnlyPage scripts cannot read it through document.cookie; it is still sent with fetch requestsAlways
SameSiteWhether it is sent with requests from other sites: Strict, Lax or None (None needs Secure)Strict or Lax
DomainLeft out, the cookie goes only to the host that set it; set, it also goes to subdomainsLeave it out
PathThe paths it is sent toAs narrow as works
Expires or Max-AgeWithout them, it ends when the browser closesOnly as long as needed

The descriptions are MDN's (Set-Cookie); the right-hand column follows OWASP, which says session cookies must explicitly set SameSite to Strict (preferred) or Lax, and that Domain should not be set (OWASP cheat sheet). A cookie whose name starts with __Host- is only accepted with Secure, no Domain and Path=/, which locks it to your exact host (MDN).

What if my app keeps the session in localStorage?

Some apps keep the session token in the browser's storage instead of a cookie. OWASP advises against it: "Do not store session identifiers in local storage as the data is always accessible by JavaScript", so a single cross-site scripting flaw can expose every token (OWASP cheat sheet). Its session guidance prefers cookies marked HttpOnly, Secure and SameSite (OWASP cheat sheet). If you keep the token in storage, a strict content security policy and careful handling of user input matter even more; see the security headers guide.

How do I check my session, step by step?

Six checks in your browser, on the deployed site rather than on localhost, because the browser relaxes Secure there. Do these checks only on an app you own or have written permission to test, with test accounts you created.

  1. Find the session cookie

    Sign in, open the developer tools, then Application, Storage, Cookies, and select your site (Chrome DevTools). Sign out and back in: the cookie that disappears and comes back is the session. If none does, look under Local Storage for a token.

  2. Read its flags

    The table shows HttpOnly, Secure and SameSite for each cookie. For the session cookie, HttpOnly and Secure should be ticked and SameSite should read Lax or Strict. A Domain that starts with a dot or names a parent domain means every subdomain receives it.

    If it fails: Set session cookies to Secure, HttpOnly and SameSite

  3. Try to read it from the page

    In the Console, type document.cookie and press Enter. If the session cookie's value appears, it is not HttpOnly, and any script running on the page can read it.

    If it fails: Set session cookies to Secure, HttpOnly and SameSite

  4. Check that sign-in starts a new session

    Note the session cookie's value before you sign in, if there is one, then sign in and compare. It should change. OWASP says the session id must be renewed after any change in privilege, such as signing in (OWASP cheat sheet).

  5. Check that sign-out ends the session on the server

    While signed in, copy a request that loads your own data ("Copy as cURL" in the Network tab). Sign out, then run the copied request. It should be refused. OWASP says logout must invalidate the session at least on the server side; deleting the cookie in the browser does not stop a copied one working (OWASP cheat sheet).

  6. Check how long a session lasts

    Leave a test account idle and see when it is signed out, and check the cookie's expiry. OWASP recommends both an idle timeout and an absolute timeout, enforced on the server, and suggests 15 to 30 minutes of idle time for low-risk apps (OWASP cheat sheet). Many consumer apps choose longer; make it a decision rather than a default.

How do I fix the flags?

Find where the cookie is set: your sign-in route, or the options of the sign-in library your AI tool used. A safe starting point is Set-Cookie: __Host-session=...; Secure; HttpOnly; SameSite=Lax; Path=/. Use SameSite=None only if another site really must send the cookie, and then Secure is required (MDN). Make sign-out delete the session on the server, not only the cookie. Then repeat the six checks.

Facts worth knowing, with sources

  • A cookie marked HttpOnly cannot be read through document.cookie but is still sent with fetch requests. Source
  • SameSite=None requires the Secure attribute. Source
  • OWASP says session cookies must explicitly set SameSite=Strict (preferred) or SameSite=Lax. Source
  • OWASP says logout must invalidate the session at least on the server side. Source

Questions

Should I use SameSite Strict or Lax for a session cookie?

OWASP prefers Strict. With Strict, someone who follows a link to your app from another site arrives signed out on that first page; Lax sends the cookie on such top-level navigations with safe methods, so it is the common compromise.

Is a token in localStorage insecure?

It can be read by any script on the page, so one cross-site scripting flaw can expose it. OWASP advises against keeping session identifiers in local storage; a cookie marked HttpOnly, Secure and SameSite is the safer default.

Why is my cookie not marked Secure on localhost?

Browsers relax the HTTPS requirement of Secure on localhost. Check the flags on your deployed site, which is what your users get.

Where does Saqr fit?

These checks cover what is on the list, on the pages you think to try. Saqr runs this kind of test on the live app for you, in a real browser and including signed-in pages, and shows the proof for each finding with a fix prompt for your AI coding tool. After you fix something, ask it to recheck. Plans are Starter at $19 a month and Pro at $49 a month, and you can cancel any time.

Every task ends in three PDFs. These are the ones from a task on a demo shop, unedited:

No test can promise an app is secure. A task tells you what Saqr found that day, with proof.

Sources

The statements above were checked against these pages on 24 November 2026. Products change; follow the links for the current wording.

  1. MDN: Set-Cookie
  2. OWASP cheat sheet: Session Management
  3. OWASP cheat sheet: HTML5 Security
  4. Chrome DevTools: View, add, edit and delete cookies