Javascript Library.
Commands 0 |
---|
Read/Write/Delete document cookies.
_z.cookie.get();
Returns: Object All cookies as Object
{ "cookie name" = "cookie value" }
_z.cookie.get(name);
Returns: String cookie value Or “”
_z.cookie.set(name, value, expire);
Returns: _z.cookie Object
_z.cookie.setBySec(name, value, expire);
Returns: _z.cookie Object
_z.cookie.delete(name);
Returns: _z.cookie Object
To delete all the cookies you can use:
_z.cookie.get().each( (x)=>_z.cookie.delete(x)&&x );
_z.cookie.set("user", "admin"); // cookie="user=admin" and expires when the browsing session ends
_z.cookie.set("pass", "123"); // cookie="user=admin; pass=123" and expires when the browsing session ends
_z.cookie.delete("pass"); // cookie="user=admin" and expires when the browsing session ends
_z.cookie.setBySec("pass", "123", 60); // cookie="user=admin;" and expires when the browsing session ends, cookie="pass=123" and expires after 60 seconds
_z.cookie.get("user"); // {user: "admin"}
_z.cookie.get(); // {user: "admin", pass: "123"}