DEPRICATION WARNING: the functionality in this script has been superceeded / trivialised by updated web standards.
A library of useful functions to ease working with cookies.
This include can be added to the header or placed inline before the script is invoked.
<script src="js/cookies.js"></script>
Or use Require.js.
requirejs([
'js/cookies.js'
], function(cookies) {
...
});
Or use imported as a component in existing projects.
@import {cookies} from "js/cookies.js');
``
## How to control the script
### load
```javascript
value = cookies.load(name);
Retrieves a value from a cookie.
name : {string} - Name of a parameter stored as a cookie.
value : {string} - Returned value of the named parameter stored as a cookie.
cookies.save(name, value, expires, path, domain, secure);
Saves a name-value pair to a cookie.
name : {string} - Name of a parameter stored as a cookie.
value : {string} - Value to be stored as a cookie.
expires : {object} - A date object setting the expiration date of the cookie.
path : {string} - URL path for which the cookie is valid.
domain : {string} - Domain for which the cookie is valid.
secure : {boolean} - Specifies if the cookie is supposed to be secure.
cookies.clear(name, path, domain);
Clears a name-value pair from a cookie.
name : {string} - Name of a parameter stored as a cookie.
path : {string} - URL path for which the cookie is valid.
domain : {string} - Domain for which the cookie is valid.
This work is licensed under a MIT License. The latest version of this and other scripts by the same author can be found on Github.