Search code examples
jquerycookies

integrating jQuery Cookie


Hi i have this pseudo code:

if(cookie set){
    $("#notification").hide();
}
else {
    $("#notification").show();
}

How can i integrate the jQuery Cookie plugin, so if it finds a cookie then it doesnt show the #notification?


Solution

  • if ($.cookie('whatever')) {
      //exists
    } else {
      //nuthin!
    }
    

    Providing you are using: http://plugins.jquery.com/project/Cookie

    [edit] you can also:

    if ($.cookie('whatever') !== null) {
      //exists
    } else {
      //still nuthin
    }