Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to store the needed session data in localStroage instead of a cookie? #423

Open
2 tasks
mooglin opened this issue Jan 7, 2014 · 10 comments
Open
2 tasks

Comments

@mooglin
Copy link

mooglin commented Jan 7, 2014

  • options for setting localStorage / add-on
  • PhoneGap example

I'm trying to use socketstream with phonegap. The session becomes lost when the app is restarted, the cookie does not persist. I was thinking I could store the needed data in localStroage because that does seem to persist.

Is this possible? What data needs to be stored/updated?

The goal is autologin / persistent login between app restarts, not just page reloads, which already works.

@drauschenbach
Copy link

This is more of an Engine.IO question if you ask me. I'm working on the same thing right now. In short, Engine.IO uses document.cookie, which in a Hybrid or web situation would have been populated with the Connect session. But in a stand-alone PhoneGap app, this document.cookie should be pre-populated in advance (and stored in local storage), instead of being left blank. Apparently, the more mature SockJS-client does something equivalent.

@mooglin
Copy link
Author

mooglin commented Jan 9, 2014

@drauschenbach So do you think switching the transport to use sock.js would solve the problem?

ss.ws.transport.use(require('ss-sockjs'));

@drauschenbach
Copy link

I've just solved this on my end by avoiding the issue altogether... I switched my app to Hybrid by telling PhoneGap to download an external http URL instead of an embedded one. SockJS is worth a try, but you also need to turn on storage of cookies for file:// URLs so that the cookies get saved between mobile app sessions.

@mooglin
Copy link
Author

mooglin commented Jan 9, 2014

@drauschenbach I tell phonegap to pull from a remote url as well, but I still hit this problem. You're using socketstream/phonegap and are getting session cookies persist between full app restarts?

@drauschenbach
Copy link

Well not exactly. My web app (PhoneGap or otherwise) uses session-scoped cookies. I do this because I don’t implement a global RPC error trap yet, which would have to reload the page as soon as my RPC functions start returning 403 due to the session having been expired by Redis on the server while the client Ember app continues to run.

On Jan 9, 2014, at 2:31 PM, mooglin notifications@github.com wrote:

@drauschenbach I tell phonegap to pull from a remote url as well, but I still hit this problem. You're using socketstream/phonegap and are getting session cookies persist between full app restarts.


Reply to this email directly or view it on GitHub.

@mooglin
Copy link
Author

mooglin commented Jan 9, 2014

@drauschenbach Ok, I guess I will look into sock.js and see if that solves the issue. @paulbjensen If you come across any details that would help please pass them along. Thanks!

@mooglin
Copy link
Author

mooglin commented Jan 9, 2014

Simply switching to sock.js did not change anything. I will keep looking into it, thanks for any help.

@paulbjensen
Copy link
Contributor

I believe that @kulicuu is looking into this issue, is that right?

@kulicuu
Copy link

kulicuu commented Feb 2, 2015

Yes, although only generally at this point. The engine.io migration turned out not to require such a major change.

@thepian thepian modified the milestones: 0.3.14, 0.3.12 Apr 5, 2015
@thepian thepian modified the milestones: 0.4.1, 0.3.14 Apr 16, 2015
@thepian thepian modified the milestones: 0.5, 0.4.3 Apr 28, 2015
@thepian thepian modified the milestones: 0.5.2, 0.5.1 Oct 18, 2015
@thepian thepian added the ready label Nov 4, 2015
@thepian
Copy link
Member

thepian commented Nov 15, 2015

@drauschenbach I will be fixing this in the coming weeks for 0.5, any experience you would like to share on this?

Is there a documentation page for PhoneGap behavior on cookies/local storage

@thepian thepian added In Progress and removed ready labels Nov 15, 2015
@thepian thepian self-assigned this Nov 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants