Skip to content

Commit 16a8b8c

Browse files
Add PHP setrawcookie docs
1 parent bad9911 commit 16a8b8c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

SERVER_SIDE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ This presents two types of problems:
1515
1. PHP writes a cookie via `setcookie()` and all spaces get converted to `+` signs. js-cookie read `+` signs and uses them literally, since it is a valid cookie character.
1616
2. js-cookie writes a cookie with a value that contains `+` signs and stores it as is, since it is a valid cookie character. PHP read a cookie and converts `+` signs to spaces.
1717

18-
To make both PHP and js-cookie play nicely together you need to write custom converters:
18+
To make both PHP and js-cookie play nicely together?
19+
20+
**In PHP**, use `setrawcookie()` instead of `setcookie()`:
21+
22+
```php
23+
setrawcookie($name, rawurlencode($value));
24+
```
25+
26+
**In JavaScript**, use a custom converter:
1927

2028
```javascript
2129
var Cookies = Cookies.withConverter({

0 commit comments

Comments
 (0)