-1

I'm making an application with PHP and a lot of Javascript. Basically the user is gonna use the application in the browser (all the javascript makes the functionanity here) without any internet for many hours.

During the usage, there will be inputs and data created. Later when the user has internet again, he need to be able to press a submit button and be able to send those processed data via POST to the server. I guess, then, when the user does that, the server would have forgoten the session and I'm afraid the data will be lost.

Is there any way to make the server know we are resuming a session that started hours ago so the data is not lost when it redirects to a login screen? (because the login session would have expired then)

Thank you

JuanBonnett
  • 734
  • 3
  • 8
  • 23
  • 2
    One word you could think about is: database. – Daan Nov 10 '14 at 15:38
  • `localstorage` - store the variables client-side. Use JS to fetch when re-connected. – Mooseman Nov 10 '14 at 15:40
  • You could give the user a cookie that your application looks for to know who it is and where the data needs to be stored like a remember me cookie you would use in a normal login system – akaBase Nov 10 '14 at 15:40
  • Yeh @Daan is right, you will need to store their user ID within your JavaScript then when an internet connection is established use that to update the database – David Jones Nov 10 '14 at 15:41
  • Thanks for replying. I've been thinking about AJAX, instead of submitting a form. The data might stay intact, the server would create a new Session and give a response to the current browser tab without redirecting. What do you guys think? – JuanBonnett Nov 10 '14 at 15:44
  • 1
    Try storing your session data in a database and increasing the cookie lifetime http://stackoverflow.com/questions/11272405/php-sessions-in-database – Machavity Nov 10 '14 at 15:46

1 Answers1

1

Have you tried to create a $_Cookie with a phpsesionid that renews when they post but the phpsession id is stored in a db and then they're able to resume on. you could probably use the phpsessionid db to keep hold of the data they had before loosing connection then grab the data back when they get connection by using the cookie.

Jamie Harding
  • 393
  • 3
  • 22