How to delete a cookie using jQuery?

To delete a cookie with JQuery, set the value to null: $.cookie(“name”, null, { path: “https://stackoverflow.com/” }); Edit: The final solution was to explicitly specify the path property whenever accessing the cookie, because the OP accesses the cookie from multiple pages in different directories, and thus the default paths were different (this was not described … Read more

jquery save json data object in cookie

You can serialize the data as JSON, like this: $.cookie(“basket-data”, JSON.stringify($(“#ArticlesHolder”).data())); Then to get it from the cookie: $(“#ArticlesHolder”).data(JSON.parse($.cookie(“basket-data”))); This relies on JSON.stringify() and JSON.parse() to serialize/deserialize your data object, for older browsers (IE<8) include json2.js to get the JSON functionality. This example uses the jQuery cookie plugin