2014-09-24 8 views
0

TideSDK를 사용하여 Windows 용 데스크톱 응용 프로그램을 개발하고 있습니다. 사용자가 로그인 할 때 입력하는 이메일 주소 정보를 저장하기 위해 쿠키를 사용하려고합니다. 다음 페이지 (mainMenu.html)가로드 될 때 이메일 주소 (내 index.html 파일)로 저장 한 쿠키가 어떻게 든 손실됩니다. 자바 스크립트 index.html을자바 스크립트가 Windows OS 페이지간에 쿠키를 검색 할 수 없습니다.

:

//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 자바 스크립트 :

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

이 내 mainMenu.html에서 경고 한 Statment는 모습입니다 같은 :

enter image description here

내 쿠키가 파일간에 저장되지 않는 이유는 무엇입니까?

미리 감사드립니다. !!!! 내가 너무 애매하거나 아무것도 남겨 두지 않으면 알려주세요. 기꺼이 설명해 드리겠습니다 !!! :)

답변

1

tidesdk가 적절하게 "브라우저"쿠키가 예상대로 작동하지 않을 수 있기 때문에. 이러한 정보를 저장하려면 JSON 구조를 사용하십시오.

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

쿠키 tidesdk는 정보를 저장하기위한 최선의 선택이 될 수 없습니다 여기 쿠키에 대한 항목을 읽어 보시기 바랍니다.