jQuery check if Cookie exists, if not create it

后端 未结 5 642
春和景丽
春和景丽 2020-12-02 20:27

I cannot get this code to work I must be missing something pretty simple. I am trying to check to see if a Cookie exists, if it does {do nothing} if it doesn\'t {create it}

5条回答
  •  清歌不尽
    2020-12-02 20:50

    Try this very simple:

                var cookieExist = $.cookie("status");
                if(cookieExist == "null" ){
                    alert("Cookie Is Null");
    
                }
    

提交回复
热议问题