Skip to content

Commit e3a19c3

Browse files
committed
Improving Readme
1 parent f2b6b25 commit e3a19c3

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,47 @@ The plugin can also be loaded as AMD or CommonJS module.
2727
Create session cookie:
2828

2929
```javascript
30-
$.cookie('the_cookie', 'the_value');
30+
$.cookie('name', 'value');
3131
```
3232

3333
Create expiring cookie, 7 days from then:
3434

3535
```javascript
36-
$.cookie('the_cookie', 'the_value', { expires: 7 });
36+
$.cookie('name', 'value', { expires: 7 });
3737
```
3838

3939
Create expiring cookie, valid across entire site:
4040

4141
```javascript
42-
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
42+
$.cookie('name', 'value', { expires: 7, path: '/' });
4343
```
4444

4545
Read cookie:
4646

4747
```javascript
48-
$.cookie('the_cookie'); // => "the_value"
49-
$.cookie('not_existing'); // => undefined
48+
$.cookie('name'); // => "value"
49+
$.cookie('nothing'); // => undefined
5050
```
5151

5252
Read all available cookies:
5353

5454
```javascript
55-
$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
55+
$.cookie(); // => { "name": "value" }
5656
```
5757

5858
Delete cookie:
5959

6060
```javascript
61-
// Returns true when cookie was found, false when no cookie was found...
62-
$.removeCookie('the_cookie');
63-
64-
// Same path as when the cookie was written...
65-
$.removeCookie('the_cookie', { path: '/' });
61+
// Returns true when cookie was successfully deleted, otherwise false
62+
$.removeCookie('name'); // => true
63+
$.removeCookie('nothing'); // => false
64+
65+
// Need to use the same attributes (path, domain) as what the cookie was written with
66+
$.cookie('name', 'value', { path: '/' });
67+
// This won't work!
68+
$.removeCookie('name'); // => false
69+
// This will work!
70+
$.removeCookie('name', { path: '/' }); // => true
6671
```
6772

6873
*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.*

0 commit comments

Comments
 (0)