You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is not currently an easy way to pass a `samesite` attribute value for setting this cookie - but you can set the
793
+
default value for the attribute for all cookies. See [the main cookies documentation](/developer_guides/cookies_and_sessions/cookies#samesite-attribute) for more information.
794
+
[/info]
795
+
787
796
For other cookies set by your application we should also ensure the users are provided with secure cookies by setting
788
797
the "Secure" and "HTTPOnly" flags. These flags prevent them from being stolen by an attacker through javascript.
The `samesite` attribute is set on all cookies with a default value of `Lax`. You can change the default value by setting the `default_samesite` value on the
62
+
[Cookie](api:SilverStripe\Control\Cookie) class:
63
+
64
+
```yml
65
+
SilverStripe\Control\Cookie:
66
+
default_samesite: 'Strict'
67
+
```
68
+
69
+
[info]
70
+
Note that this _doesn't_ apply for the session cookie, which is handled separately. See [Sessions](/developer_guides/cookies_and_sessions/sessions#samesite-attribute).
71
+
[/info]
72
+
55
73
## Cookie_Backend
56
74
57
75
The [Cookie](api:SilverStripe\Control\Cookie) class manipulates and sets cookies using a [Cookie_Backend](api:SilverStripe\Control\Cookie_Backend). The backend is in charge of the logic
Copy file name to clipboardexpand all lines: docs/en/02_Developer_Guides/18_Cookies_And_Sessions/02_Sessions.md
+15-1
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,19 @@ including form and page comment information. None of this is vital but `clear_al
101
101
$session->clearAll();
102
102
```
103
103
104
-
## Secure Session Cookie
104
+
## Cookies
105
+
106
+
### Samesite attribute
107
+
108
+
The session cookie is handled slightly differently than most cookies on the site, which provides the opportunity to handle the samesite attribute separately from other cookies.
109
+
You can change the `samesite` attribute for session cookies like so:
110
+
111
+
```yml
112
+
SilverStripe\Control\Session:
113
+
cookie_samesite: 'Strict'
114
+
```
115
+
116
+
### Secure Session Cookie
105
117
106
118
In certain circumstances, you may want to use a different `session_name` cookie when using the `https` protocol for security purposes. To do this, you may set the `cookie_secure` parameter to `true` on your `config.yml`
107
119
@@ -113,6 +125,8 @@ SilverStripe\Control\Session:
113
125
114
126
This uses the session_name `SECSESSID` for `https` connections instead of the default `PHPSESSID`. Doing so adds an extra layer of security to your session cookie since you no longer share `http` and `https` sessions.
115
127
128
+
Note that if you set `cookie_samesite` to `None` (which is _strongly_ discouraged), the `cookie_secure` value will _always_ be `true`.
129
+
116
130
## Relaxing checks around user agent strings
117
131
118
132
Out of the box, Silverstripe CMS will invalidate a user's session if the `User-Agent` header changes. This provides some supplemental protection against session high-jacking attacks.
-[Features and enhancements](#features-and-enhancements)
11
+
-[Samesite attribute on cookies](#cookies-samesite)
12
+
-[Other features](#other-features)
13
+
-[Bugfixes](#bugfixes)
14
+
15
+
## Regression test and Security audit{#audit}
16
+
17
+
This release has been comprehensively regression tested and passed to a third party for a security-focused audit.
18
+
19
+
While it is still advised that you perform your own due diligence when upgrading your project, this work is performed to ensure a safe and secure upgrade with each recipe release.
20
+
21
+
## Features and enhancements {#features-and-enhancements}
22
+
23
+
### Samesite attribute on cookies {#cookies-samesite}
24
+
25
+
The `samesite` attribute is now set on all cookies. To avoid backward compatability issues, the `Lax` value has been set by default, but we recommend reviewing the requirements of your project and setting an appropriate value.
26
+
27
+
The default value can be set for all cookies (except for the session cookie) in yaml configuration like so:
28
+
29
+
```yml
30
+
SilverStripe\Control\Cookie:
31
+
default_samesite: 'Strict'
32
+
```
33
+
34
+
Check out the [cookies documentation](/developer_guides/cookies_and_sessions/cookies#samesite-attribute) for more information.
35
+
36
+
The session cookie is handled separately. You can configure it like so:
37
+
38
+
```yml
39
+
SilverStripe\Control\Session:
40
+
cookie_samesite: 'Strict'
41
+
```
42
+
43
+
Note that if you set the `samesite` attribute to `None`, the `secure` is automatically set to `true` as required by the specification.
44
+
45
+
For more information about the `samesite` attribute check out https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
46
+
47
+
### Other new features {#other-features}
48
+
49
+
## Bugfixes {#bugfixes}
50
+
51
+
This release includes a number of bug fixes to improve a broad range of areas. Check the change logs for full details of these fixes split by module. Thank you to the community members that helped contribute these fixes as part of the release!
52
+
53
+
<!--- Changes below this line will be automatically regenerated -->
54
+
55
+
<!--- Changes above this line will be automatically regenerated -->
0 commit comments