|
2 | 2 |
|
3 | 3 | A simple, lightweight jQuery plugin for reading, writing and deleting cookies. |
4 | 4 |
|
| 5 | +== Installation |
| 6 | + |
| 7 | +Include script *after* the jQuery library (unless you are packaging scripts somehow else): |
| 8 | + |
| 9 | + <script src="/path/to/jquery.cookie.js"></script> |
| 10 | + |
5 | 11 | == Usage |
6 | 12 |
|
7 | | - // Create session cookie... |
| 13 | +Create session cookie: |
| 14 | + |
8 | 15 | $.cookie('the_cookie', 'the_value'); |
9 | 16 |
|
10 | | - // Create expiring cookie, 7 days from then... |
| 17 | +Create expiring cookie, 7 days from then: |
| 18 | + |
11 | 19 | $.cookie('the_cookie', 'the_value', { expires: 7 }); |
12 | 20 |
|
13 | | - // Create expiring cookie, valid across entire page... |
| 21 | +Create expiring cookie, valid across entire page: |
| 22 | + |
14 | 23 | $.cookie('the_cookie', 'the_value', { expires: 7, path: '/' }); |
15 | 24 |
|
16 | | - // Read cookie... |
| 25 | +Read cookie: |
| 26 | + |
17 | 27 | $.cookie('the_cookie'); // => 'the_value' |
18 | 28 | $.cookie('not_existing'); // => null |
19 | 29 |
|
20 | | - // Delete cookie by passing null as value... |
| 30 | +Delete cookie by passing null as value: |
| 31 | + |
21 | 32 | $.cookie('the_cookie', null); |
22 | 33 |
|
23 | 34 | == Options |
@@ -47,6 +58,8 @@ Default: +false+. If true, the cookie transmission requires a secure protocol (h |
47 | 58 | Default: +false+. By default the cookie is encoded/decoded when creating/reading, using +encodeURIComponent+/+decodeURIComponent+. |
48 | 59 | Turn off by setting +raw: true+. |
49 | 60 |
|
| 61 | +== Changelog |
| 62 | + |
50 | 63 | == Development |
51 | 64 |
|
52 | 65 | - Source hosted at {GitHub}[https://github.com/carhartl/jquery-cookie] |
|
0 commit comments