jQuery check if Cookie exists, if not create it
I think the bulletproof way is: if (typeof $.cookie(‘token’) === ‘undefined’){ //no cookie } else { //have cookie } Checking the type of a null, empty or undefined var always returns ‘undefined’ Edit: You can get there even easier: if (!!$.cookie(‘token’)) { // have cookie } else { // no cookie } !! will turn … Read more