3. Cookie attributes & cookie design

9 cards

Review this deck
All cards in this deck

Secure

The cookie is only sent over HTTPS; mandatory for every MemberPortal cookie.

HttpOnly

JavaScript cannot read the cookie via `document.cookie`; stops XSS from stealing the session id.

SameSite=Lax

The cookie is not sent on cross-site POST/iframe requests, but is still sent on top-level GET navigation (needed for the redirect from the IdP back to the callback).

SameSite=Strict vs Lax

Strict also blocks the cookie when the user returns from the IdP via redirect → the callback has no SessionID1; that is why the OIDC callback uses Lax.

Why `sid` has no Expires

Redis is the single source of truth for session lifetime (absolute TTL); the cookie only carries the id. Do not rely on "closing the browser clears it" because browsers can restore session cookies.

Why `xsrf` is not HttpOnly

Frontend JS must read it to attach it to the `X-XSRF-TOKEN` header; the value is useless if the attacker does not also have `sid`.

`uid` cookie

Holds the sub so the UI can display/distinguish accounts; it has no security value because the BFF never uses it to grant access.

`APP_SSO_TOKEN` cookie

A 64-hex opaque token injected into the WebView by the native app; the BFF only reads it and verifies it server-to-server, never creates it and must not delete it on 401.

User-Agent is only for routing

The UA can be spoofed, so the BFF only uses it to decide between the app flow and the web flow, never to grant access.

3. Cookie attributes & cookie design – Flashcards – Login Flow | Học Dev