Loading…

How to create, read and delete cookies with jQuery?

1. Set a cookie

$.cookie("example", "foo"); // Sample 1
$.cookie("example", "foo", { expires: 7 }); // Sample 2
$.cookie("example", "foo", { path: '/admin', expires: 7 }); // Sample 3

2. Get a cookie

alert( $.cookie("example") );

3. Delete the cookie

$.removeCookie("example");

Suggest An Answer

No suggestions avaliable!

Latest post from JQuery interview questions

Ask Question