# Manage Cookies with Express

> Learn how to manage cookies in Express with the res.cookie() method, set options like httpOnly, secure, and expires, and clear one with res.clearCookie().

Author: Flavio Copes | Published: 2018-09-23 | Updated: 2019-09-02 | Canonical: https://flaviocopes.com/express-cookies/

Use the `Response.cookie()` method to manipulate your cookies.

Examples:

```js
res.cookie('username', 'Flavio')
```

This method accepts a third parameter, which contains various options:

```js
res.cookie('username', 'Flavio', { domain: '.flaviocopes.com', path: '/administrator', secure: true })

res.cookie('username', 'Flavio', { expires: new Date(Date.now() + 900000), httpOnly: true })
```

The most useful parameters you can set are:

Value | Description
---------|----------
`domain` | 	The [cookie domain name](https://flaviocopes.com/cookies/#set-a-cookie-domain)
`expires` | Set the [cookie expiration date](https://flaviocopes.com/cookies/#set-a-cookie-expiration-date). If missing, or 0, the cookie is a session cookie
`httpOnly` | 	Set the cookie to be accessible only by the web server. See [HttpOnly](https://flaviocopes.com/cookies/#httponly)
`maxAge` |  Set the expiry time relative to the current time, expressed in milliseconds
`path` | 	The [cookie path](https://flaviocopes.com/cookies/#set-a-cookie-path). Defaults to '/'
`secure` | 	Marks the [cookie HTTPS only](https://flaviocopes.com/cookies/#secure)
`signed` | 	Set the cookie to be signed
`sameSite` | Value of [`SameSite`](https://flaviocopes.com/cookies/#samesite)

A cookie can be cleared with:

```js
res.clearCookie('username')
```
