I was having alot of trouble with this because I was using:
if($.cookie('token') === null || $.cookie('token') === "")
{
//no cookie
}
else
{
//have cookie
}
The above was ALWAYS returning false, no matter what I did in terms of setting the cookie or not. From my tests it seems that the object is therefore undefined before it's set so adding the following to my code fixed it.
if($.cookie('token') === null || $.cookie('token') === ""
|| $.(cookie('token') === "null" || $.cookie('token') === undefined)
{
//no cookie
}
else
{
//have cookie
}