PDA

View Full Version : Need help on Session management of Sencha touch



sapna_kotresh
19 Jun 2011, 11:18 PM
Hi All,

I want to manage session in my app, I am using php as backend, after authenticating the user at server end, on success am redirecting the login page to next page, at server when I check whether the user is authenticated( in redirected page) :
1) on smart phones it gives me unauthenticated
2)on web page accessing through google chrome it gives me authenticated.

I could draw out that normal session authentication(server session's) won't work as usual, so we need to store on authentication at sencha touch end using sessionStorage.setItem("loggedIn", true), now how do I find that session is expired?.

Is my understanding right. Please guide me.

ardnet
30 Jun 2011, 9:22 PM
I had the same problem too, subscribing.
Anyone can share some thoughts here?

Thanks

sapna_kotresh
30 Jun 2011, 10:27 PM
Hi ardnet,

What am doing is

1)Call server check for authentication using ajax function
2)on authentication in ajax function set sessionStorage.setItem("loggedIn", true)
3)0n failure in ajax function set sessionStorage.setItem("loggedIn", false)
4)Actually sessionStorage data exist for that particular tab(browser), if you close that, you need to login again. So this is one way of getting session expired.
5)Start a timer on a page, say if you want to keep a person logged in for x sec then after x sec set sessionStorage.setItem("loggedIn", false) and redirect page to login.

This is what I am following, hopefully it helps you.

ardnet
30 Jun 2011, 10:34 PM
Hi ardnet,

What am doing is

1)Call server check for authentication using ajax function
2)on authentication in ajax function set sessionStorage.setItem("loggedIn", true)
3)0n failure in ajax function set sessionStorage.setItem("loggedIn", false)
4)Actually sessionStorage data exist for that particular tab(browser), if you close that, you need to login again. So this is one way of getting session expired.
5)Start a timer on a page, say if you want to keep a person logged in for x sec then after x sec set sessionStorage.setItem("loggedIn", false) and redirect page to login.

This is what I am following, hopefully it helps you.

Hey sapna_kotresh,
Thanks a lot for the reply, but just wondering will this work in PhoneGap?
Nevermind, let me try first then I'll let you know if I got some problem.

Cheers,
Ardi

ardnet
7 Jul 2011, 7:03 AM
Hi sapna_kotresh,
Mind sharing the code for that? ;)
been struggling with this quite some actually.

Thanks in advance.

Ardi

sapna_kotresh
11 Jul 2011, 3:39 AM
Hi ardnet,

Just realized what was the basic root cause of this problem. I was basically checking in iphone, for the browser(say safari) there is a setting called 'accept cookies', it was set to never. This was the problem. So please check out in your smart phone too.