DELAPARRA
Index
Color
NL
Category: HTTP headers

Set-Cookie

Explained by Updated

What is Set-Cookie?

Set-Cookie: Server tells the browser to store a cookie. Can include flags like HttpOnly, Secure, SameSite. Set-Cookie is the response header a server uses to tell the browser to store a cookie, such as Set-Cookie: session=abc; HttpOnly; Secure; SameSite=Lax; Path=/. The flags matter for security. HttpOnly stops JavaScript from reading the cookie, which protects session cookies from being stolen through cross-site scripting. Secure sends the cookie only over HTTPS. SameSite=Lax or Strict limits when the cookie is sent with requests from other sites, which helps against cross-site request forgery.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Set-Cookie

What should you keep in mind with Set-Cookie?

Set an expiry with Max-Age or Expires, or the cookie disappears when the browser closes. Keep cookies small and few, because they travel with every request to your domain. Frameworks like Laravel set sensible defaults for session cookies, but check them, especially Secure in production.

What does an example of Set-Cookie look like?

Set-Cookie: session=abc; HttpOnly; Secure; SameSite=Lax; Path=/

At a glance

CategoryHTTP headers
Explained by
Updated

More HTTP headers terms

All terms starting with S

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.