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.
By Saqr. Last checked .
What does each cookie setting do?
| Setting | What it does | What to use for a session |
|---|---|---|
| Secure | The cookie is only sent over HTTPS | Always |
| HttpOnly | Page scripts cannot read it through document.cookie; it is still sent with fetch requests | Always |
| SameSite | Whether it is sent with requests from other sites: Strict, Lax or None (None needs Secure) | Strict or Lax |
| Domain | Left out, the cookie goes only to the host that set it; set, it also goes to subdomains | Leave it out |
| Path | The paths it is sent to | As narrow as works |
| Expires or Max-Age | Without them, it ends when the browser closes | Only 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.
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.
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
Try to read it from the page
In the Console, type
document.cookieand 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
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).
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).
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:
- Summary for owners (PDF, 6 pages). What was found and what to fix first.
- Technical report for developers (PDF, 29 pages). Every finding, with its proof and the steps to fix it.
- AI fix pack (PDF, 10 pages). A ready-to-paste fix prompt for every finding.
No test can promise an app is secure. A task tells you what Saqr found that day, with proof.
Which other guides should I read?
- Is my Lovable app secure?
- Is my Bolt app secure?
- Is my Replit app secure?
- Is my v0 app secure?
- Is my Cursor-built app secure?
- Is my Supabase app secure?
- Is my Firebase app secure?
- How do I check if my vibe-coded app is secure?
- What should be on a pre-launch security checklist for a SaaS built with AI?
- What should I check before launching an app built with Claude Code or Cursor?
- What is the OWASP Top 10, in plain words?
- How do I test my own app for broken access control (IDOR)?
- How do I test Supabase row level security?
- Supabase anon key vs service_role key: which one is safe in the browser?
- How do I check if a Supabase storage bucket is public?
- How do I check my Firebase security rules?
- My Firebase API key is public. Is that safe?
- I exposed an API key in my frontend. What do I do now?
- How do I add and test login rate limiting in an app built with AI tools?
- Which security headers should my Next.js or Vite app set?
- Is my CORS configuration safe, and how do I check it?
- Security fix prompts for your AI coding tool
- Saqr, automated scanners and a manual penetration test
- Questions about securing an app built with AI tools
To see what a finished test looks like, open the sample reports.
Sources
The statements above were checked against these pages on 24 November 2026. Products change; follow the links for the current wording.