Session management in Blackberry Webworks

让人想犯罪 __ 提交于 2019-12-09 22:56:56

问题


I want to be develop a blackberry application.That used an external DB through webservice call.I am choosing blackberry web works for developing this.I want to store a userid in phone like session after logged in a user.How use session management in BB webworks?

help is highly appreciated.

Thanks, Comp


回答1:


You can use either SQLlite or Cookies. Cookies are extremly useful and easy to implement for non critical data:

function setCookie(c_name,value,exdays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    try{
        document.cookie=c_name + "=" + c_value;
    }catch(e){
        alert('exception: ' + e.name + '; ' + e.message);
    }

}
function getCookie(c_name){
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
      x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
      y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
      x=x.replace(/^\s+|\s+$/g,"");
      if (x==c_name)
        {
        return unescape(y);
        }
    }
}

Good luck!



来源:https://stackoverflow.com/questions/4828735/session-management-in-blackberry-webworks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!