Skip to content

Commit

Permalink
Add heading about the __Host- prefix (#7245)
Browse files Browse the repository at this point in the history
  • Loading branch information
eashaw committed Aug 10, 2022
1 parent d666ada commit e4184a5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/reference/sails.config/sails.config.session.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ The recommended production session store for Sails.js is Redis... but we realize

The built-in session integration in Sails works by using a session ID cookie. This cookie is [HTTP-only](https://www.owasp.org/index.php/HttpOnly) (as safeguard against [XSS exploits](https://sailsjs.com/documentation/concepts/security/xss)), and by default, is set with the name "sails.sid".


##### The "__Host-" prefix.

By default, cookies have no integrity against same-site attackers.

In production enviroments, we recommend that you prefix the "name" of your cookie (`sails.config.session.name`) with "__Host-" to limit the scope of your cookie to a single origin.

You can read more about the "__Host-" prefix [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes).

```js
session: {
name: '__Host-sails.sid'
}
```

> Note: Adding this prefix requires the ["secure" flag](#the-secure-flag) to be set to `true`.
##### Expiration

The maximum age / expiration of your app's session ID cookie can be set as a number of milliseconds.
Expand Down

0 comments on commit e4184a5

Please sign in to comment.