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-sitePOSTforms, iframes, and subrequests, while allowing them on safe top-levelGETnavigations (like clicking a link from an email).None: Allows cross-site cookies everywhere, but requires theSecure(HTTPS) flag or browsers reject it.
Practical Takeaways
- Default to
SameSite=Laxfor login sessions:Strictbreaks expected UX when users click notification links and land logged out. PairLaxwith anti-CSRF tokens for defense in depth. - Know Same-Site vs. Same-Origin:
app.example.comandapi.example.comare different origins (requiring CORS) yet same-site (sharing eTLD+1example.com), soSameSite=Laxcookies still work between them. - Test OAuth/payment POST callbacks: Cross-site
POSTredirects from external identity or payment providers won't carryLaxcookies—plan state handoffs accordingly.
Notable Examples
- Standard session cookie recipe:
HttpOnly; Secure; SameSite=Lax; Path=/. - Cross-domain embedded widgets: Explicitly setting
SameSite=None; Securewhere third-party cookie context is required.