# Cookie attributes
*Cookies & privacy*
Mark session cookies Secure and HttpOnly, and set SameSite so other sites cannot send them by accident.

## Why it matters
A session cookie is the key to a logged-in account. Without HttpOnly, a single script injection can read it; without Secure, it can travel over plain HTTP.
SameSite blocks another site from triggering logged-in actions in the background. It is one of the cheapest protections against request forgery.

## How to fix it
1. Set Secure and HttpOnly on session cookies
2. Set SameSite=Lax, or Strict for sensitive actions
3. Keep expiry short and rotate the session on login

## Prompt for an AI assistant
Copy the text below and paste it into an AI assistant.
```text
You are the person improving this website. Check the item below and fix it if it applies to the site.

Item: Cookie attributes
Summary: Mark session cookies Secure and HttpOnly, and set SameSite so other sites cannot send them by accident.
Steps:
1. Set Secure and HttpOnly on session cookies
2. Set SameSite=Lax, or Strict for sensitive actions
3. Keep expiry short and rotate the session on login
References:
- Set-Cookie (MDN) (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
- Session Management (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html)

Constraints:
- Keep the existing design and tone of voice.
- Show the file or section you changed and the suggested final wording.
- Do not decide ambiguous points alone; give options and a recommendation.
- Do not change anything outside the listed item.
```

## Checked by
- **[vuln](https://ismyappok.com/en/vuln/checks)** — Public exposure checks

## Related checks
- **[Caching of personalised pages](https://ismyappok.com/en/checks/cache-with-cookies)** — Do not mark pages that depend on a cookie as publicly cacheable.
- **[Content-Security-Policy (CSP)](https://ismyappok.com/en/checks/csp)** — Send a Content-Security-Policy that limits where scripts, styles, and frames can come from, instead of allowing everything.

## References
- **[Set-Cookie (MDN)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)** — MDN (Mozilla) reference（Official）
- **[Session Management (OWASP)](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html)** — OWASP cheat sheet（Reference）

## Check your site now
Enter a URL and find what is missing before launch, for free.
[Run audit](https://ismyappok.com/en/audit/check)