Group
  • Security

    Lock down my session cookie flags

    Sets HttpOnly, Secure, and SameSite on session cookies and fixes session tokens stored in localStorage.

    • Improve quality
    • Debug & fix
    • Beginner
    • Replit
    • Cursor
    • Bolt
    • Lovable
    • General

Free Prompt

Review how my app stores and sends session tokens. Look at the cookie configuration on the server and any client-side code that reads or stores tokens (check localStorage and sessionStorage usage). Apply these requirements: session cookies must be set with HttpOnly (so JavaScript can't read them), Secure (so they only travel over HTTPS), and SameSite=Lax or Strict (so other sites can't send them). Set a reasonable max age. If session tokens are currently stored in localStorage and attached to requests manually, explain the XSS risk that creates and move them into an HttpOnly cookie instead. Do not change how long users stay logged in beyond setting a sane default. Do not break login persistence or the logout flow. If the app needs to work over plain HTTP in local development, show me how to keep that working without weakening production settings (environment-based config). Show me the before and after for every change. End with verification steps: how to inspect the cookie in browser dev tools and confirm each flag is present, and how to confirm a session token no longer appears in localStorage.

What This Does / How This Helps

Fixes the two session mistakes vibe-coded apps make constantly: cookies set without HttpOnly, Secure, and SameSite flags, and session tokens parked in localStorage where any injected script can read them. A token readable by JavaScript is a token one XSS bug away from being stolen, and a cookie without SameSite can be sent along with forged requests from other sites. These are the quiet misconfigurations that turn a small bug into full account takeover. You'll get each change shown before and after, plus dev-tools verification steps so you can confirm the flags are actually set in the browser.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts