Skip to content

Commit 5ce4b3a

Browse files
authored
Merge pull request #3664 from nepikn/patch-2
Update article so 'samesite=lax' is the default behavior
2 parents e2ac312 + 4a20875 commit 5ce4b3a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

6-data-storage/01-cookie/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ alert( document.cookie ); // cookie1=value1; cookie2=value2;...
3131
```
3232

3333

34-
The value of `document.cookie` consists of `name=value` pairs, delimited by `; `. Each one is a separate cookie.
34+
The value of `document.cookie` consists of `name=value` pairs, delimited by `;`. Each one is a separate cookie.
3535

36-
To find a particular cookie, we can split `document.cookie` by `; `, and then find the right name. We can use either a regular expression or array functions to do that.
36+
To find a particular cookie, we can split `document.cookie` by `;`, and then find the right name. We can use either a regular expression or array functions to do that.
3737

3838
We leave it as an exercise for the reader. Also, at the end of the chapter you'll find helper functions to manipulate cookies.
3939

@@ -214,7 +214,7 @@ The cookie `samesite` option provides another way to protect from such attacks,
214214

215215
It has two possible values:
216216

217-
- **`samesite=strict` (same as `samesite` without value)**
217+
- **`samesite=strict`**
218218

219219
A cookie with `samesite=strict` is never sent if the user comes from outside the same site.
220220

@@ -230,7 +230,7 @@ When a user follows a legitimate link to `bank.com`, like from their own notes,
230230

231231
We could work around that by using two cookies: one for "general recognition", only for the purposes of saying: "Hello, John", and the other one for data-changing operations with `samesite=strict`. Then, a person coming from outside of the site will see a welcome, but payments must be initiated from the bank's website, for the second cookie to be sent.
232232

233-
- **`samesite=lax`**
233+
- **`samesite=lax` (same as `samesite` without value)**
234234

235235
A more relaxed approach that also protects from XSRF and doesn't break the user experience.
236236

@@ -255,7 +255,7 @@ Overall, `samesite` is a great option.
255255

256256
There's a drawback:
257257

258-
- `samesite` is ignored (not supported) by very old browsers, year 2017 or so.
258+
- `samesite` is ignored (not supported) by very old browsers, the year 2017 or so.
259259

260260
**So if we solely rely on `samesite` to provide protection, then old browsers will be vulnerable.**
261261

@@ -269,7 +269,7 @@ The web-server uses the `Set-Cookie` header to set a cookie. Also, it may set th
269269

270270
This option forbids any JavaScript access to the cookie. We can't see such a cookie or manipulate it using `document.cookie`.
271271

272-
That's used as a precaution measure, to protect from certain attacks when a hacker injects his own JavaScript code into a page and waits for a user to visit that page. That shouldn't be possible at all, hackers should not be able to inject their code into our site, but there may be bugs that let them do it.
272+
This is used as a precautionary measure, to protect from certain attacks when a hacker injects his own JavaScript code into a page and waits for a user to visit that page. That shouldn't be possible at all, hackers should not be able to inject their code into our site, but there may be bugs that let them do it.
273273

274274

275275
Normally, if such a thing happens, and a user visits a web-page with hacker's JavaScript code, then that code executes and gains access to `document.cookie` with user cookies containing authentication information. That's bad.

0 commit comments

Comments
 (0)