---
title: "NUXT_E7011"
description: "A cookie could not be written."
canonical_url: "https://nuxt.com/docs/4.x/errors/e7011"
---
# E7011

`useCookie()` could not serialize a cookie for the `Set-Cookie` header or `document.cookie`. The original error is attached as `cause`. It is raised when:

- the cookie name contains characters that are not allowed in a cookie name, such as spaces, `;` or `=`
- the value returned by a custom `encode` contains characters that are not allowed in a cookie value
- the attributes are inconsistent, for example `sameSite: 'none'`, `partitioned: true` or a `__Secure-` / `__Host-` name without `secure: true`, or a `__Host-` cookie with a `domain`
- an attribute is invalid, for example a `maxAge` that is not an integer

## Resolution

Use a valid cookie name, return an encoded string from `encode`, and set `secure: true` for cookies that require it:

```ts
const token = useCookie('token', {
  sameSite: 'none',
  secure: true,
})
```

::read-more{to="https://nuxt.com/docs/4.x/api/composables/use-cookie"}
::


## Sitemap

See the full [sitemap](https://nuxt.com/sitemap.md) for all pages.
