Forum Moderators: coopster

Message Too Old, No Replies

Keeping session alive

Users spending a long time over form and timed out after submission

         

hughie

11:21 am on Feb 14, 2007 (gmt 0)

10+ Year Member



Hi All

I've built an app for a client that allows selected users to input a load of product sales data, from which returns some handy stats.

What's happening is that users are spending a long time over the form input so when the user hits submit (in one case over an hour later) the session has died, the user logged out and the data is lost.

Is it possible to maintain a session for that length of time, either via .htaccess or some other cunning piece of PHP ingenuity?

or do i have to go away and write a script which captures the form input when it times them out, so it's back there when the log in.

Any help would be greatly appreciated as usual

Hughie

eelixduppy

12:40 pm on Feb 14, 2007 (gmt 0)



Have you looked at using session_gc_maxliftime [us2.php.net] or session_cookie_lifetime [us2.php.net]?

This should provide a solution :)

hughie

1:02 pm on Feb 14, 2007 (gmt 0)

10+ Year Member



i have but i'm not sure they provide the answer (+ it takes ages to check whether each one does), be good to know if anyones had a similar issue and what they've done about.

eelixduppy

1:03 pm on Feb 14, 2007 (gmt 0)



I don't think it would take ages. If you set the value so that the cookie expires when the browser is closed, then right there you have solved your problem.

mcavic

3:19 am on Feb 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



using session_gc_maxliftime or session_cookie_lifetime

Yes, I would expire the cookie when the browser is closed, and expire the session itself after maybe 5 days.

hughie

9:08 am on Feb 15, 2007 (gmt 0)

10+ Year Member



sorry for the slow reply, got buried yesterday arvo

I'll give that a whirl and leave it on my test system for a few hours and see what happens.

However i have implemented a system using javascript to refresh a 1x1 pixel php image which seems to have done the trick as well. Probably overkill but, once you get going on something it seems a shame to stop.

thanks,
hughie

whoisgregg

8:34 pm on Feb 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If they are spending that much time working on the form perhaps submitting the form in the background with AJAX periodically as an "auto save" feature would both keep their session alive and prevent them from losing all their work due to browser/computer/network failure.

It'd be more work to implement such a feature but I bet your client would love it. :)

hughie

10:47 pm on Feb 15, 2007 (gmt 0)

10+ Year Member



that would be cool, not done much with ajax but there's a little project if ever there was one....