redirect with post after session expire

Go To StackoverFlow.com

3

I have such a mechanism of handling expired sessions:

User logged in
Session expires
User goes to link
User redirected to login page
User logs in
User redirected to requested link

What I would like to achieve is to have the same functionality with forms, as such:

User logged in
User starts to fill out a form
Session expires
User submits a form
User redirected to login page
User logs in
Form posted on behalf of user (aka redirect with post)

But as of now it works like this:

User logged in
User starts to fill out a form
Session expires
User submits a form
User redirected to login page
User logs in
User redirected to form page with all fields empty
User sad

I've tried to to it with http_redirect, but turns out it just adds parameters to the URL. The problem is, the server side does not accept GET, only POST. I've been trying to think of other ways to do this, like Autosave feature, javascript posting and redirection, etc.

Somebody must've experienced this problem before.

Any ideas?

2012-04-04 06:29
by donk
I think you can save the data in a session itself. That is, after you notice that the session has been expired when the user submits the form, store the data that he entered in a session and redirect him to the login page. After the user has logged in and is redirected back to the form page, you can populate the form fields using the data in the session - Joris 2012-04-04 06:41


1

There are several ways that i think

1) increase session.gc_maxlifetime value to higher (1 day or more). If using own session, same logic for it.

2) Make session never expire unless user logout

3) When user submit POST and session expire, store form data to session itself and after redirect get data from session. Or use get method after redirect

4) Continously check session with ajax (ping). For example every 60 seconds. Unless browser not close, session will never expire (for me its best solution)

5) Use ajax for from submit, if session expire pop a dialog box for re-login

There could be another options of course

2012-04-04 06:45
by safarov


0

You could go for the following:

User logged in
User starts to fill out a form
Session expires

User submits a form
Server sees session has expired
Server creates new session
Server stores post in session variable $_SESSION['post'] = $_POST
User redirected to login page

User logs in
Server verifies user etc
Server checks for data in $_SESSION['post']
Server sets $_POST = $_SESSION['post']
Form posted on behalf of user
2012-04-04 06:51
by P O'Conbhui
Ads