Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
Posts: 7
Registered: ‎04-17-2013
My Device: z10
My Carrier: Rogers

How to keep a user logged in

Similar to Facebook, Twitter, and other apps, I only have to log in once unless I log out myself. How can I do this for my WebWorks app?

 

My app simply hosts a web page that does all the authentication. I'm guessing it writes a cookie to the device but then removes the cookie with the app closes. I am required to login every time I open the app. This is a pain!

 

 

Retired
Posts: 165
Registered: ‎09-24-2012
My Device: Passport
My Carrier: Bell

Re: How to keep a user logged in

Hi curious_george,

 

Are you sure the cookie gets cleared? From my experience, the cookies remain even after restarting the app.

 

You can run document.cookie within Web Inspector (or do console.log(document.cookie) in JavaScript to see the values.

 

Let me know what the above returns after a) the server sets the cookie b) the app restarts

 

Cheers.

 

 

New Contributor
Posts: 5
Registered: ‎04-16-2013
My Device: BB Deve Alpha
My Carrier: Movistar

Re: How to keep a user logged in

Hi, unfortunately cookies do not remain after app is closed.


What I suggest is to use localstorage.

 

For eg.

window.localStorage.setItem('cookieContent',content);

 

And then in the app initialization properties you can set the cookie with document.cookie = window.localStorage.getItem('cookieContent');

 

You've to check if the item exists and all the stuff.

 

If my answer was helpfull please like my post.

Highlighted
New Contributor
Posts: 7
Registered: ‎04-17-2013
My Device: z10
My Carrier: Rogers

Re: How to keep a user logged in

Thanks for the responses. I didn't get a chance to check if the server cookie gets set and what happens when re-opening the app. I decided not to call web page url's from my app. I went with BBUI.js to re-create the front-end and implemented web service calls to get the data from the server. I am using localStorage to store authentication info and sending with each web service call. Thus, the cookie scenerio is no longer applicable.