Skip to main content
Web DevAuth & SecurityDiagramBeginner

SameSite Cookie Attribute

KO: SameSite 쿠키 속성·EN: SameSite Cookie Attribute·JA: SameSite Cookie属性

A cookie attribute (Strict, Lax, or None) that controls whether browsers send cookies on cross-site requests to defend against CSRF attacks

Table of Contents

Structure Diagram

SameSite=Strict vs SameSite=Lax Cookie Behavior
StrictSameSite=Strict

Max security · Never sent cross-site

  • External Link ClickCookie omitted on first landing
  • Cross-Site POST / iframeCompletely blocked
  • Best FitBanking, sensitive admin actions
LaxSameSite=Lax (Default)

Balanced · Allows top-level GET

  • External Link ClickSent on top-level GET navigation
  • Cross-Site POST / iframeBlocked (blocks POST CSRF)
  • Best FitStandard web app login sessions
Quick Answer

What is SameSite Cookie Attribute?

A cookie attribute (Strict, Lax, or None) that controls whether browsers send cookies on cross-site requests to defend against CSRF attacks. It is a core concept in Auth & Security within Web Dev.

Core Principles

The SameSite cookie attribute tells browsers whether to attach a cookie on cross-site requests:

  • Strict: Sent only in first-party contexts; omitted even when clicking an external link into your site.
  • Lax (modern browser default): Blocks cookies on cross-site POST forms, iframes, and subrequests, while allowing them on safe top-level GET navigations (like clicking a link from an email).
  • None: Allows cross-site cookies everywhere, but requires the Secure (HTTPS) flag or browsers reject it.

Practical Takeaways

  • Default to SameSite=Lax for login sessions: Strict breaks expected UX when users click notification links and land logged out. Pair Lax with anti-CSRF tokens for defense in depth.
  • Know Same-Site vs. Same-Origin: app.example.com and api.example.com are different origins (requiring CORS) yet same-site (sharing eTLD+1 example.com), so SameSite=Lax cookies still work between them.
  • Test OAuth/payment POST callbacks: Cross-site POST redirects from external identity or payment providers won't carry Lax cookies—plan state handoffs accordingly.

Notable Examples

  • Standard session cookie recipe: HttpOnly; Secure; SameSite=Lax; Path=/.
  • Cross-domain embedded widgets: Explicitly setting SameSite=None; Secure where third-party cookie context is required.