惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
M
MIT News - Artificial intelligence
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
博客园_首页
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
F
Fortinet All Blogs
腾讯CDC
罗磊的独立博客
IT之家
IT之家
I
InfoQ
V
V2EX
博客园 - 叶小钗
A
About on SuperTechFans
Y
Y Combinator Blog
C
Check Point Blog
量子位
Martin Fowler
Martin Fowler
Vercel News
Vercel News

Vercel News

Vercel Open Source Program: Winter 2026 cohort How Notion Workers run untrusted code at scale with Vercel Sandbox How we run Vercel's CDN in front of Discourse From idea to secure checkout in minutes with Stripe Building Slack agents can be easy Scaling redirects to infinity on Vercel Advancing Python typing Gamma builds design-first agents with Vercel How Avalara turns pipe dreams into patent-pending with v0 Keeping community human while scaling with agents How OpenEvidence built a healthcare AI that physicians actually trust Security boundaries in agentic architectures Skills Night: 69,000+ ways agents are getting smarter Video Generation with AI Gateway We Ralph Wiggumed WebStreams to make them 10x faster How Stably ships AI testing agents in hours, not weeks How we built AEO tracking for coding agents Anyone can build agents, but it takes a platform to run them Introducing Geist Pixel The Vercel AI Accelerator is back with $6m in credits Making agent-friendly pages with content negotiation The Vercel OSS Bug Bounty program is now available Introducing the new v0 Run untrusted code with Vercel Sandbox, now generally available How Stripe built a game-changing app in a single flight with v0 How Sensay went from zero to product in six weeks AGENTS.md outperforms skills in our agent evals Agent skills explained: An FAQ Testing if "bash is all you need" AWS databases are now live on the Vercel Marketplace and v0
Understanding the SameSite cookie attribute - Vercel – Ve...
Lydia Hallie · 2023-10-02 · via Vercel News

2 min read

Explore the SameSite cookie attribute's significance in ensuring web security and user privacy to strike the right balance between security and usability.

Navigating the web safely while ensuring user privacy is a top priority. When working with cookies, it’s important to ensure they are secure and serve their intended purpose without compromising user privacy.

One key attribute to consider is SameSite, which dictates when and how cookies are sent in cross-site requests.

Link to headingWhat Are Cookies?

Cookies are small data pieces that web browsers save on user devices when websites ask them to. They help websites remember things about users, like their preferences or what's in their shopping cart.

However, with growing concerns about unwanted data sharing and potential security risks, there's a need to control when and where these cookies are used. That's where the SameSite attribute steps in, allowing developers to specify when a cookie is sent based on where the request comes from. This attribute can be set to Strict, Lax, or None to fit various needs.

Link to headingStrict

When a cookie's SameSite attribute is set to Strict, it means the cookie will be sent only if the request originates from the same site.

Use Cases:

  • Ideal for high-security applications like online banking.

  • Prevents any cross-site usage, ensuring high levels of data confidentiality.

Link to headingLax

The Lax setting strikes a balance between usability and security. With this setting, the cookie:

  • Won't be sent on cross-site subresource requests, such as images, stylesheets, and scripts.

  • Will be sent for top-level navigations, like when a user clicks on a link leading to the site.

Use Cases:

  • Useful for content embedded on other sites where some degree of cross-site interaction is okay.

  • Enhances the browsing experience by maintaining sessions even when users arrive from an external link.

If the SameSite attribute isn't set, browsers will treat the cookie as if it were set to Lax.

Link to headingNone

For the cookie to be sent with every request, including cross-site ones, the SameSite attribute should be set to None.

However, when using SameSite=None, the cookie must also be marked as Secure, meaning it can only be transported over HTTPS. If you attempt to set a cookie with SameSite=None without the Secure attribute on an HTTPS site, the browser will likely show a warning in the console, and the cookie won't function as intended!

Use Cases:

  • Cross-site tracking, often used by advertising platforms.

  • Single Sign-On systems that require authentication across various domains.

  • Functionalities intended for direct use by external websites.

Deciding which configuration to use depends on your specific use case.

  • Want top-notch security? Go with Strict. This guarantees the cookie is only ever sent to its origin, minimizing the risk of CSRF attacks or unintentional leaks.

  • Want a mix of user-friendliness and safety? Go with Lax. This ensures a smoother user experience while still offering protection against potential threats.

  • Need to share cookie data across sites? Go with None. Just remember to also set it to Secure.

Link to headingConclusion

The SameSite attribute offers web developers granular control over cookies, enhancing web security and ensuring a better user experience. By understanding the nuances of Strict, Lax, and None, you can make more informed decisions, keeping users both happy and secure.