sveltejs/kit · warning
'${name}' cookie does not exist for ${url.pathname}, but was
Error message
'${name}' cookie does not exist for ${url.pathname}, but was previously set at ${conjoin([...paths])}. Did you mean to set its 'path' to '/' instead? What it means
When reading a cookie via `cookies.get(name)` at a URL path where it does not exist, but the cookie was previously set during the same request at a more specific path, SvelteKit warns. Cookies are path-scoped, so a cookie set with `path: '/admin'` is invisible to `get()` calls at other paths. The warning suggests you probably wanted the cookie visible everywhere and should set `path: '/'`.
Source
Thrown at packages/kit/src/runtime/server/cookie.js:116
}
if (best_match) {
return best_match.options.maxAge === 0 ? undefined : best_match.value;
}
const cookie = parse_header(opts)[name]; // the decoded string or undefined
// in development, if the cookie was set during this session with `cookies.set`,
// but at a different path, warn the user. (ignore cookies from request headers,
// since we don't know which path they were set at)
if (DEV && !cookie) {
const paths = Array.from(cookie_paths[name] ?? []).filter((path) => {
// we only care about paths that are _more_ specific than the current path
return path_matches(path, url.pathname) && path !== url.pathname;
});
if (paths.length > 0) {
console.warn(
// prettier-ignore
`'${name}' cookie does not exist for ${url.pathname}, but was previously set at ${conjoin([...paths])}. Did you mean to set its 'path' to '/' instead?`
);
}
}
return cookie;
},
getAll(opts) {
// copy, so the cached parse isn't mutated below
const cookies = { ...parse_header(opts) };
// Group cookies by name and find the most specific one for each name
const lookup = new Map();
for (const c of new_cookies.values()) {
if (matches_url(c)) {View on GitHub (pinned to 03f1687fe6)
Solutions
- Set the cookie with `path: '/'` so it is readable at every URL path.
- Read the cookie from the same path scope where it was set, or explicitly pass the matching path semantics in your own logic.
- If the path scoping is intentional, ignore/restructure the code so `get` is only called within the scoped path.
Example fix
// before
cookies.set('session', token, { path: '/account' });
// after
cookies.set('session', token, { path: '/' }); Defensive patterns
Strategy: validation
Validate before calling
// always validate the path option when setting cookies
function setSessionCookie(cookies, name, value) {
if (!options.path || options.path !== '/') {
console.warn(`cookie ${name} set with path ${options.path}; will not be readable site-wide`);
}
cookies.set(name, value, { path: '/', ...options });
} Prevention
- Default every `cookies.set` call to `path: '/'` unless path scoping is deliberate.
- Centralize cookie set/get in one helper module so path options are consistent.
- Test cookie reads from a different route than the one that sets them.
When it happens
Trigger: In one request: `cookies.set('session', value, { path: '/settings' })` then later `cookies.get('session')` at a URL like `/` or another pathname — `get` finds no cookie for the current path but the set-cookie path matches more specifically, triggering the warn.
Common situations: Setting a login or preference cookie inside a nested route action/hook without specifying `path`, then reading it elsewhere on the site during the same or subsequent request handling.
Related errors
- "${key}" header is already set
- Cannot use `cookies.set(...)` after the response has been ge
- ${node.server_id}: Accessing URL properties in a promise han
- ${node.server_id}: Calling `event.fetch(...)` in a promise h
- ${node.server_id}: Calling `depends(...)` in a promise handl
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/a09052b6d6eae38e.
Report an issue: GitHub.