multichild — 2013-01-16T07:13:46-05:00 — #1
I have recently created a small CMS using php and MySQL and my client is complaining that the page is timing out too quickly for him, as he basically starts typing an sometimes goes away to verify info and maybe take some pics.
I def havent set the timeout of the page, so there nothing there controlling it, so wondered how would I go about handling this timeout length.
cpradio — 2013-01-16T07:21:07-05:00 — #2
Are you referring to the fact that his session expires and he is logged out while writing his page?
One thing you could do, is convert from using $SESSION to $COOKIE and setcookie(). Another alternative is to extend the session lifetime.
multichild — 2013-01-16T07:27:52-05:00 — #3
Yes and no, as it doesnt time out as he is typing i dont think, I think its when its inactive, as he pops off to do something else having already started typing somethng into the admin a while back.
But yes when he comes back and carries on typing, and clicks submit, rather than it uploading it goes straight to the log in page instead, having been logged out
starlion — 2013-01-16T08:59:27-05:00 — #4
The idea here isnt to stop his session from timing out - it's to hold his entered data while he logs back in, and then pass that data back in.
If your system detects a timeout (No session value);
Start a session (should be done anyway)
Serialize $_POST as an item (i'm gonna call it 'formdata') in the session.
Save the target page as another session variable. (if your login form is using PHP_SELF, you dont need to worry about this)
Present login page.
Now the login parser needs a bit more logic.
If the login was successful;
Unset the login post variables;
Unserialize anything in $SESSION['formdata'] back into $POST (yes, this is naughty but it works)
load the page as normal.
multichild — 2013-01-16T10:00:10-05:00 — #5
OK I see yes, i will give this a go and may return.
Well, probably will return.