getCookie(name) Last updated: 20. Oct 2026
API only function
Reads a cookie sent with the request. Available in API scripts and the site router.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The cookie name. |
Returns
The value as text, or null when the request has no cookie with that name.
Docly's own cookies (auth, auth2, adminoverride, access_token and _doauth_*) always return null — use request.user and request.Jwt. A cookie set with setCookie in the same request is not visible until the next request.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// #/Services/Router.js — check the state on a sign-in callback
if (!query.state || query.state !== docly.getCookie("oauth_state"))
return route.text("The sign-in has expired. Please try again.", 400);