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
Copy file name to clipboardExpand all lines: README.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# jquery.cookie
1
+
# jquery.cookie
2
2
3
3
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
4
4
@@ -42,30 +42,50 @@ Delete cookie:
42
42
43
43
## Configuration
44
44
45
+
### raw
46
+
45
47
By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true:
46
48
47
49
$.cookie.raw = true;
48
50
51
+
### json
52
+
49
53
Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`:
50
54
51
55
$.cookie.json = true;
52
56
53
57
## Cookie Options
54
58
59
+
### expires
60
+
55
61
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.
56
62
57
63
expires: 365
58
64
59
65
Define lifetime of the cookie. Value can be a `Number` which will be interpreted as days from time of creation or a `Date` object. If omitted, the cookie becomes a session cookie.
60
66
67
+
### path
68
+
61
69
path: '/'
62
70
63
71
Define the path where the cookie is valid. *By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior).* If you want to make it available for instance across the entire domain use `path: '/'`. Default: path of page where the cookie was created.
64
72
73
+
**Note regarding Internet Explorer:**
74
+
75
+
> Due to an obscure bug in the underlying WinINET InternetGetCookie implementation, IE’s document.cookie will not return a cookie if it was set with a path attribute containing a filename.
76
+
77
+
(From [Internet Explorer Cookie Internals (FAQ)](http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx))
78
+
79
+
This means one cannot set a path using `path: window.location.pathname` in case such pathname contains a filename like so: `/check.html` (or at least, such cookie cannot be read correctly).
80
+
81
+
### domain
82
+
65
83
domain: 'example.com'
66
84
67
85
Define the domain where the cookie is valid. Default: domain of page where the cookie was created.
68
86
87
+
### secure
88
+
69
89
secure: true
70
90
71
91
If true, the cookie transmission requires a secure protocol (https). Default: `false`.
0 commit comments