Use the cookie attributes for their purpose

The Secure attribute tells a browser to send a cookie only over HTTPS. HttpOnly prevents browser scripts from reading it. SameSite can reduce some cross-site request risks.

These flags do not replace safe session handling or server-side access checks. Set an appropriate cookie path, domain and lifetime for each application.

Rotate sessions after important events

Create a new session identifier after sign-in and privilege changes. Invalidate the old session after sign-out, password reset or account compromise.

Keep session identifiers out of URLs and logs. Avoid long-lived sessions on shared or high-risk devices unless the product has a clear, secure design for them.

Check the live response

Inspect Set-Cookie headers from production and staging. Confirm every authentication cookie has the intended flags and does not expose a broad domain to unrelated applications.

Test sign-in, sign-out, account recovery and permission changes. Include the session behaviour in an application security review.