Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript无法在Windows操作系统页面之间检索Cookie_Javascript_Windows_Cookies_Tidesdk - Fatal编程技术网

Javascript无法在Windows操作系统页面之间检索Cookie

Javascript无法在Windows操作系统页面之间检索Cookie,javascript,windows,cookies,tidesdk,Javascript,Windows,Cookies,Tidesdk,我正在使用TideSDK为windows开发一个桌面应用程序。我试图使用cookie来存储用户登录时输入的电子邮件地址的信息。我为电子邮件地址保存的cookie(在index.html文件中)在加载下一页(mainMenu.html)时不知何故丢失了 index.html Javascript: //this is what I call when the login information is correct function setCookie(cname,cvalue,exdays

我正在使用TideSDK为windows开发一个桌面应用程序。我试图使用cookie来存储用户登录时输入的电子邮件地址的信息。我为电子邮件地址保存的cookie(在index.html文件中)在加载下一页(mainMenu.html)时不知何故丢失了

index.html Javascript:

//this is what I call when the login information is correct



function setCookie(cname,cvalue,exdays) {

             var d = new Date();
             d.setTime(d.getTime() + (exdays*24*60*60*1000));
             var expires = "expires=" + d.toGMTString();
             document.cookie = cname+"="+cvalue+"; "+expires;

             }

        function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
        }
        return "";
        }


        setCookie("email",em,30); //setting the cookie

        window.location.href = "mainMenu.html"; // go to the next page 
//当登录信息正确时,我会调用此函数
函数setCookie(cname、cvalue、exdays){
var d=新日期();
d、 设置时间(d.getTime()+(exdays*24*60*60*1000));
var expires=“expires=“+d.togmString();
document.cookie=cname+“=”+cvalue+”;“+expires;
}
函数getCookie(cname){
变量名称=cname+“=”;
var ca=document.cookie.split(“;”);

对于(var i=0;i,因为tidesdk不是一个合适的“浏览器”,cookies可能无法按预期工作。请使用JSON结构保存此类信息。请阅读此处有关cookies的主题

Cookie可能不是tidesdk存储信息的最佳选项

//this is what I call when the page gets loaded

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
    }
    return "";
}
   alert("email: "+getCookie("email"));