Set-Cookie

The response header a server uses to ask the browser to store a cookie, together with attributes that limit where it is sent.

In more detail

One Set-Cookie header sets one cookie, with a name, a value and attributes such as Path, Expires, HttpOnly, Secure and SameSite. The browser applies the attributes each time it decides whether to send the cookie back.

Examples

In the browser: Set-Cookie: session=abc; HttpOnly; Secure; SameSite=Lax is a sensible default for a login cookie.
Set-Cookie: session=abc; HttpOnly; Secure; SameSite=Lax
Set-Cookie: __Host-sess=tok_xyz; Path=/; Max-Age=3600; HttpOnly; Secure; SameSite=Strict
Set-Cookie: session=abc123; Secure; HttpOnly; SameSite=Lax; Path=/
The course builds Set-Cookie with a helper that turns on Secure, HttpOnly and SameSite=Lax by default, so a caller has to name a flag to lose it, which makes opting out searchable in review.

Related terms

Taught in

References