Javascript cannot retrieve cookies between Windows OS pages

I am using TideSDK to develop a desktop app for windows. I am trying to use a cookie to store the information of the email address that a user enters on login. The cookie that I save for the email address (on my index.html file) somehow becomes lost when the next page (mainMenu.html) loads.

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 

mainMenu.html Javascript:

//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"));

This is what the alert statment from my mainMenu.html looks like:

Why is my cookie not saved between files?

Thank you in advance!!!! Please let me know if I was too vague or left anything out, I will gladly explain myself!!! :)

Answers


Since tidesdk is not properly a "browser" cookies may not work as expected. use a JSON structure to save such information. Please read the topic about your cookies here

TideSDK How to save a cookie's information to be accessed in different file?

Cookies may not be the best option for tidesdk to store information.


Need Your Help

sed , awk or python in shell script

python

I have a shell script with the following line to remove double quotes " from a text file.

Poker EV calculator: Computing Hand Value?

java if-statement switch-statement poker

I am attempting to write a program that helps a user make the correct EV play for each hand. However at the minute I am using card value (i.e. total of two cards) to base my decisions. For example ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.