How do I set/unset cookie with jQuery? -
How can I set and set cookies using jQuery, for example View the plugin: < / P> You can then: To delete: Additionally, to set a fixed amount of fixed days (10 here) on the cookie: If the timeout option is omitted, the cookie becomes a session cookie, and the browser is deleted when exited. To cover all options: To read the value of the cookie: You would like to specify the path parameter, if the cookie was created on a different path than the current one: As mentioned in the comments below, the team working on the original plugin has removed jquery dependency a new project () In which the same functionality and general syntax is as jquery version. Apparently the original plugin is not going anywhere. test Create a cookie and set the value to
1
$ Cookie ("test", 1);
$. Removecookie ("test");
$. Cookie ("test", 1, {expiration: 10});
$ The cookie ("test", 1, {expires: 10, // 10 day path is ending: '/', // the value of the path attribute of the cookie // (default: path of the cookie page) domain: 'Jquery.com', // the value of the domain's attribute of the cookie // (default: the domain of the page that creates the cookie): safe: true // If the cookie's safe feature is set / and cookie transmission / / Will need a secure protocol (default to false).});
var cookieValue = $ .cookie ("test");
var cookieValue = $ .cookie ("test ", {Path: '/' Foo '}); Update (April 2015):
Comments
Post a Comment