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=LaxSet-Cookie: __Host-sess=tok_xyz; Path=/; Max-Age=3600; HttpOnly; Secure; SameSite=StrictSet-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
- cookie — A small named value a server asks a browser to store and send back automatically on later matching requests.
- HttpOnly — A cookie attribute that stops scripts running in the page from reading the cookie, while the browser still sends it on requests.
- SameSite — A cookie attribute that limits whether the browser sends the cookie on requests started by other websites.
- Secure attribute — A cookie attribute that tells the browser to send the cookie only over encrypted HTTPS connections.
Taught in
- Cookies And CORS — Modern API Architecture: REST, GraphQL & gRPC
- Client Storage Paradigms: Cookies, Storage Tradeoffs — Frontend Architecture & Web Platform
- CSRF Mitigations, SameSite Cookies And Subresource Integrity — Frontend Architecture & Web Platform
- Session Architecture: HTTP-Only Cookies vs Tokens — Production Full-Stack Engineering
- Secure Defaults — Application Security & Threat Modeling for Engineers