# Cookies

The implementation of cookies is close to recent browser's implementations (`Set-Cookie` header). Dappy only does HTTP+TLS therefore all cookies are forced to `secure: true`. Javascript have no access to cookies in any circumstances: all cookies also are forced to `httpOnly: true`. Only possible values for `sameSite` are `strict` or `lax`.

### **Cookies isolation**

Cookies are always tied to two scopes. The first scope is the host into which the page has been loaded (first level navigation). The second scope is the host of the web request.

Examples of scopes:

```
// (1) image loaded from https://amazoonimgs in amazoon tab
amazoon.amazoonimgs
// (2) XHR call to from https://microsooftdata in amazoon tab
amazoon.microsooftdata
// (3) XHR call to from https://microsooftdata in pinterost tab
pinterost.microsooftdata
```

Cross-scope cookie sharing is forbidden, in the above examples, cookies set at (2) and (3) are not shared. `microsooftdata`'s web server will receive either the cookies set under the navigation (scopes) on `amazoon`, or the cookies set under the navigation (scope) of `pinterost`.

Cookies are scoped instead of being not scoped. Many web services use cookies for authentication, a front-end attack on `pinterost` or any random websites will never be able to send requests that include cookies that were set on `amazoon`.

**Cookies isolation prevents 95%+ of** [**CRSF attacks**](https://owasp.org/www-community/attacks/csrf)**.**

[HTTP Working Group's take on cookies, sameSite and XSS requests (2016)](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1)
