2012-07-27 6 views
-1

안녕하세요. 저는 phonegap을 사용하여 응용 프로그램을 개발하고 있습니다. 내 응용 프로그램은 안드로이드와 블랙 베리에서 잘 작동하지만 심비안에서는 작동하지 않습니다. 내가 좋아하는 쿠키를 설정 페이지 중 하나에 쿠키가 심비안에서 작동하지 않습니다.

: 다른 페이지에서

$.cookie("userName", userName, { path: '/' }); 
$.cookie("currentTime", currentTime, { path: '/' }); 

내가 좋아하는 액세스하려고 :

alert($.cookie('userName')); 

을하지만 경고 쇼 '널 (null)', 비록 동일한 코드 안드로이드와 블랙 베리에서 완벽하게 작동합니다.
Symbian은 쿠키를 지원합니까?

답변

0

당신은하지 않습니다

setCookie('cookieName', value, cookieExpiry); 

와 쿠키를 설정하고 노키아의

getCookie('cookieName') 
0

WGZ 위젯으로 그 값을 얻을 수 있습니다 테스트

에 대한
// Function that create a cookie and set its value 
function setCookie(name, value, expiryDate) { 
document.cookie = escape(name) + "=" + escape(value) + "; path=/" + 
    ((expiryDate == null) ? "" : "; expires=" + expiryDate.toGMTString()); 
} 


// Function that gets the cookies value 
function getCookie(name) { 
var cookieName = name + "="; 
var documentCookie = document.cookie; 
var start, end; 

if(documentCookie.length > 0) { 
    start = documentCookie.indexOf(cookieName); 
    if(start != -1) { 
     start += cookieName.length; 
     end = documentCookie.indexOf(";", start); 
     if(end == -1) end = documentCookie.length; 

     return unescape(documentCookie.substring(start, end)); 
    } 
} 
return null; 
} 

를 대체 JS 코드를 사용해보십시오 쿠키를 지원하지만, 해결 방법으로 위젯을 사용하기 시작했지만 localStorage 객체처럼 사용했습니다. 여기에 조각은 ... 나는

건배 도움이되기를 바랍니다

if (!window.localStorage) { 

if(typeof(widget)==='undefined') 
{ 
//alert('working with an OS5 blackberry'); 
window.localStorage = { 
getItem: function (sKey) { 
    if (!sKey || !this.hasOwnProperty(sKey)) { return null; } 
    return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1")); 
}, 
key: function (nKeyId) { return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/, "").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]); }, 
setItem: function (sKey, sValue) { 
    if(!sKey) { return; } 
    document.cookie = escape(sKey) + "=" + escape(sValue) + "; path=/"; 
    this.length = document.cookie.match(/\=/g).length; 
}, 
length: 0, 
removeItem: function (sKey) { 
    if (!sKey || !this.hasOwnProperty(sKey)) { return; } 
    var sExpDate = new Date(); 
    sExpDate.setDate(sExpDate.getDate() - 1); 
    document.cookie = escape(sKey) + "=; expires=" + sExpDate.toGMTString() + "; path=/"; 
    this.length--; 
}, 
hasOwnProperty: function (sKey) { return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); } 
}; 
window.localStorage.length = (document.cookie.match(/\=/g) || window.localStorage).length; 
} 
else 
{ 
//alert('working with widgets'); 
window.localStorage={ 
getItem: function (sKey) { 
    return widget.preferenceForKey(sKey); 
}, 

setItem: function (sKey, sValue) { 
    widget.setPreferenceForKey(sValue, sKey); 
}, 
length: 0, 
removeItem: function (sKey) { 
    widget.setPreferenceForKey(null,sKey); 
}, 
hasOwnProperty: function (sKey) { 
    return widget.preferenceForKey(sKey)!==null; 
} 
}; 
} 
}  
관련 문제