简体   繁体   中英

Why this JQuery Cookie value dosen't update?

I just want to set the cookie as 'es' if it's undefined. But, this code dosen't work.

//UELS: GLOBALS
//Set 3 globals vars

//Where you are
var masterPage   = $('meta[name=description]').attr("content");
//Which language you are using
//If undefined [new cookie]:
    //Set ES as default language
    if ($.cookie('lang') == undefined){
        $.cookie("lang", "es");
    }
alert($.cookie('lang'));
var masterLang   = $.cookie('lang')+"_";
//Languages' usher
var callCenter   = {};
//Caller var
var current_lang = masterLang+masterPage;

The alert should show 'es' but the cookie never changes. I put an alert in the condition and it showed, so the if statement works fine.

Any idea?

I was running the web from XAMPP and it dosen't work fine. I try it out there and works perfectly. Didn't know why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM