alorel / alo-cookie
A simple JavaScript cookie manager
Installs: 183
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:HTML
Type:project
This package is not auto-updated.
Last update: 2022-02-01 12:49:23 UTC
README
What is this sorcery ?
It's a simple class to manipulate cookies in an object-oriented manner.
Usage
Get all document cookies
var cookies = AloCookie.getAll();
// {name1:value1, name2:value2 ...}
Setting cookie "foo"
var cookie = new AloCookie("foo");
cookie.value = "bar";
cookie.expire = 3600; //in 1 hour. Defaults to expire at the end of the session
cookie.domain = "www.example.com"; //defaults to window.location.hostname
cookie.path = "/cart/checkout"; // Defaults to "/"
cookie.secure = true; // true sends the cookie only via HTTPS. Defaults to window.location.protocol == "https:"
cookie.save()
Check if cookie called "foo" exists
var cookie = new AloCookie("foo"),
cookieExists = cookie.exists();
Deleting cookie "foo"
var cookie = new AloCookie("foo");
cookie.remove();