Cookies

Cookie isolation is on by default. Server code does not notice; page scripts might.

Why it exists

Every app's address ends in shim.live, so a browser treats all of them as one site. Without protection, one app could set a cookie that another app receives, or overwrite another app's cookie.

What isolation does

With cookies = "isolated", the default:

  • A cookie your app sets is stored in the browser under the name __Host-app- followed by your name, tied to your app's exact address, with Path=/ and Secure. A Domain or Path attribute you set is dropped.
  • On the way back, your app receives the cookie under the name it used. Server code reads and writes cookies as usual.
  • Cookies that do not carry the prefix never reach your app. That is what keeps other apps' cookies out.

What it means for page scripts

JavaScript in the page sees the browser's names, not yours:

  • document.cookie shows __Host-app-theme=dark, not theme=dark.
  • A cookie a script writes as theme=dark is not sent on to your app.

Cookies marked HttpOnly, such as session cookies, are not affected, because scripts never see them.

Turning it off

Turn isolation off only if your page scripts read or write cookies by name.

cookies = "shared"

Set it in shim.toml and deploy, or use the Cookie isolation switch in the app's Settings in the dashboard. With "shared", cookie names pass through unchanged in both directions. A Domain attribute is still dropped, so a cookie is only ever set for your app's own address.

Reserved names

Cookie names that start with __Host-shim belong to Shim. Your app never receives them and cannot set them.