Header overview

CORS & Cookies

Cross-origin access and browser state

Browsers normally apply the same-origin policy to limit how scripts from one origin can read resources from another. Cross-Origin Resource Sharing, or CORS, uses HTTP response headers to relax that restriction for selected origins, methods, or request headers when cross-origin access is actually required.

Cookies have their own browser rules. Attributes such as Secure, HttpOnly, and SameSite influence when cookies are sent and whether client-side scripts may access them. CORS and cookies meet most visibly in credentialed cross-origin requests, where broad wildcard permissions are not valid substitutes for an explicitly allowed origin.

Core concepts

Where CORS and cookies meet

The useful question is not whether every related header exists. It is whether browser access is intentionally limited to what the application actually needs.

Origin permission

Access-Control-Allow-Origin tells the browser which external origin may read the response through CORS. Public resources may intentionally allow broad access, while private APIs usually need a narrower policy.

Credentialed requests

Reading a credentialed cross-origin response requires an explicit allowed origin and Access-Control-Allow-Credentials: true. The client must request credentials, and browser cookie restrictions still apply.

Cookie boundaries

Secure limits cookie transmission to HTTPS, HttpOnly blocks ordinary JavaScript access, and SameSite controls cookie delivery in cross-site situations. The correct combination depends on what the cookie is used for.

Key controls

Four things worth recognizing

CORS behavior is distributed across several response headers, while cookie protection is expressed through attributes on Set-Cookie.

Origin

Access-Control-Allow-Origin

Defines which origin may access a response through browser CORS rules. The minimum necessary origin scope is generally preferable where access does not need to be public.

Read the Access-Control-Allow-Origin reference

Credentials

Allow-Credentials

Access-Control-Allow-Credentials: true tells browsers that a cross-origin response may be exposed when the request includes credentials such as cookies or HTTP authentication.

Read about CORS credentials

Preflight

Methods & Headers

Preflight responses can declare which methods and request headers are permitted before the browser sends a non-simple cross-origin request.

Read about CORS preflight

Cookies

Set-Cookie attributes

Secure, HttpOnly, SameSite, Path, Domain, and lifetime attributes define important parts of cookie transport, script access, cross-site behavior, and scope.

Read about cookie attributes

Want to go deeper?

If you would like to read more about CORS & Cookies, check out the Knowledge Base for detailed references, configuration guidance, common browser errors, and practical server examples.

Browse Knowledge Base

Copyright ©2026 MILAN INNOVATIONS LLC. All rights reserved.