Managing cookies
View, add and edit the cookies a workspace sends and receives.
Overview
Each workspace has its own cookie jar. When a response sets a cookie, Relay saves it in the jar of the request's workspace, and sends it with later requests in that workspace whose URL it matches, the way a browser would. Cookies set by a response along a redirect chain are saved too.
Because the jar belongs to the workspace, logging in with a request in one workspace doesn't affect requests in another. Cookies are stored on your Mac. They aren't part of the workspace's files, so sharing a workspace folder doesn't share its cookies.
The jar's cookies are also sent with:
- The handshake of a WebSocket connection, whose
Set-Cookieheaders are saved to the jar. - Requests a script sends with
relay.sendRequest. - GraphQL schema requests.
View a workspace's cookies
- In the sidebar, click the workspace menu and choose Edit Workspaces….
- Select the workspace.
- Click Cookies.
The tab groups cookies by domain, with the number of cookies on each domain's card. Click a card's header to collapse or expand it. A cookie whose expiry date has passed shows an Expired badge and isn't sent.
Globals have no cookies. Selecting Globals and clicking Cookies shows that cookies belong to workspaces.
Turn automatic cookies on or off
At the top of the Cookies tab, the Enable cookies switch controls the whole jar. It's on by default.
When you turn it off, Relay neither saves cookies from responses nor sends the jar's cookies. The cookies already in the jar stay there, so you can turn it back on later.
To leave the jar out of a single request, add a Cookie header to the request in its Headers tab. When a request has its own enabled Cookie header, Relay sends that header instead of the jar's cookies.
Edit, add and remove cookies
To change a cookie's name or value, edit it in its row.
To change its other attributes, click the attributes button at the end of the row. The sheet shows:
- Domain: The domain the cookie is sent to, such as
example.com. - Path: The path it's sent for. An empty path becomes
/. - Name and Value: The cookie's name and value. A cookie needs a name.
- Has expiry date: Turn on to set an expiry date in Expires. Turn off to make it a session cookie.
- Secure (HTTPS only): Send the cookie only over HTTPS.
- HTTP only: Whether the server marked the cookie as HTTP only.
- Host-only (no Domain attribute): Whether the server set the cookie without a Domain attribute.
- SameSite: None, Lax or Strict.
Click Save to apply the changes.
To add a cookie, click Add Cookie. The new cookie appears under (no domain). Enter its name and value, then click its attributes button and set its domain.
To remove a cookie, click the Remove button (−) at the end of its row. To remove every cookie in the jar, click Clear All.
You can undo any change to cookies, including Clear All, with Edit > Undo.
Read cookies in scripts
In a post-response script, relay.cookies holds the cookies the response set:
const session = relay.cookies.get("session_id");
test("Sets a session cookie", () => {
expect(relay.cookies.has("session_id")).to.be.true;
});See Also
- Understanding workspaces: Learn how workspaces, collections, folders and drafts fit together.
- Adding headers: Send headers with a request and control which ones are included.
- Sending requests from scripts: Send other requests from a script and use their responses.