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
// Returns true when cookie was successfully deleted, otherwise false
62
-
$.removeCookie('name'); // => true
63
-
$.removeCookie('nothing'); // => false
62
+
Cookies.remove('name'); // => true
63
+
Cookies.remove('nothing'); // => false
64
64
65
65
// Need to use the same attributes (path, domain) as what the cookie was written with
66
-
$.cookie('name', 'value', { path:'/' });
66
+
Cookies.set('name', 'value', { path:'/' });
67
67
// This won't work!
68
-
$.removeCookie('name'); // => false
68
+
Cookies.remove('name'); // => false
69
69
// This will work!
70
-
$.removeCookie('name', { path:'/' }); // => true
70
+
Cookies.remove('name', { path:'/' }); // => true
71
71
```
72
72
73
73
*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.*
By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true:
80
80
81
81
```javascript
82
-
$.cookie.raw=true;
82
+
Cookies.raw=true;
83
83
```
84
84
85
85
### json
86
86
87
87
Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`:
88
88
89
89
```javascript
90
-
$.cookie.json=true;
90
+
Cookies.json=true;
91
91
```
92
92
93
93
## Cookie Options
94
94
95
-
Cookie attributes can be set globally by setting properties of the `$.cookie.defaults` object or individually for each call to `$.cookie()` by passing a plain object to the options argument. Per-call options override the default options.
95
+
Cookie attributes can be set globally by setting properties of the `Cookies.defaults` object or individually for each call to `Cookies.set()` by passing a plain object to the options argument. Per-call options override the default options.
96
96
97
97
### expires
98
98
@@ -134,15 +134,15 @@ to a different representation on the fly.
134
134
Example for parsing a value into a number:
135
135
136
136
```javascript
137
-
$.cookie('foo', '42');
138
-
$.cookie('foo', Number); // => 42
137
+
Cookies.set('foo', '42');
138
+
Cookies.get('foo', Number); // => 42
139
139
```
140
140
141
141
Dealing with cookies that have been encoded using `escape` (3rd party cookies):
0 commit comments