Revision: 34323
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 21, 2010 03:27 by vagrantradio
Initial Code
//set cookies
$("#div").toggle(function() { //create div toggle
$("#div").slideUp("slow"); //create effect
$.cookie('cookie_name', 'value', {expires: 7}); //set cookie expire in 7 days
},
function () { //continue the toggle
$("#div").slideDown("slow"); //create effect
$.cookie('cookie_name', 'value'); //set cookie
});
//get cookie
alert( $.cookie("cookie_name") );
//check for cookies
var cookie_name = $.cookie('cookie_name'); //set cookie var
if (cookie_name == 'value') { //if equals this val
$("#div").hide(); //do this
};
//check for null cookies
var cookie_name = $.cookie('cookie_name'); //set cookie var
if (cookie_name == null) { // if empty
$("#div").hide(); //do this
};
//null cookies, same as getting
$.cookie("cookie_name", null);
Initial URL
http://www.vagrantradio.com/2009/10/getting-and-setting-cookies-with-jquery.html
Initial Description
How to set, get, check for and remove cookies with jQuery.
Initial Title
Set, Get, Check and Null Cookies with Jquery
Initial Tags
Initial Language
jQuery