Re: Auto session timeout
| From: | John W. Holmes | Date: | Mon, 21 Jul 2003 01:32:10 +0000 |
| Subject: | Re: Auto session timeout | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156001@lists.php.net to get a copy of this message | ||
Hardik Doshi wrote:
Hi, I have implemented the Auto session timeout after the specific period of time. What i am doing is..At the time of login to the system, my script is storing the current unix time into the session and later on at every user click, It (my script) is checking the stored unix time with the current time. So, if you want to auto logout the user after 30 minutes of inactivity then you need to store auto session timeout interval to 30 min. Algorith is..If session stored time + auto session timeout interval > current time then my script automatically logout the user from the system otherwise my script stores the current unix time in the session. My problem is.. If user is doing some work on the particular page (Ex. user is writing some stuff on the specific page) but my script is counting this thing to inactive period.. so after 31 minutes if user is completing the writing and hit submit button then he is getting the session expired screen and he is loosing all the contents on that particular page.. Please let me know if any one has solution for this.What you could do, at the point you realize the session has times out, is save the contents of $_GET, $_POST, or $_REQUEST (depending upon your script) and the current URL of the page in the session. Have the user log in again. The "login validation" page then checks for the saved values, and if they are there, redirects back to that page. Then the user doesn't lose anything. It'll require a little work, but short of increasing your time-out limit, that's the best option. There's no way to tell if a user is working on filling out a page or has left the browser open. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com