Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

WoollyMittens/useful-cookies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cookies.js: Cookies Library

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.

How to include the script

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.

save

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.

clear

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.

License

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.

About

A library of useful functions to ease working with cookies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published