Re: Session Checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 9, 2012, at 2:40 PM, Floyd Resler <fresler@xxxxxxxxxxxxx> wrote:

> I want to have an alert pop up to let the user know their session is about to expire.  Would the best approach be to do a timer in Javascript or check it in PHP.  I'm storing session data in a MySQL database so I can know when a session will expire.  If I check it through PHP will the session expiration refresh when I check it?
> 
> Thanks!
> Floyd

Floyd:

If this was my problem, my solution would be:

1. A PHP script that recorded (via MySQL) the date/time when the user successfully accessed something private (i.e., password protected).

2. The next time the user requested protected-access again, I would have the script look at the last time the user accessed this data and see IF the time period between accesses (then and now) exceeded an established time limit. If so, then deny access. If not, then reset the timer and allow access.

That's the way it would work on the server-side. 

However, the server-side really has no efficient way to notify the user their session is "about" to expire -- instead that should take place client-side and without question, you'll need a client-side JavaScript timer.

The client-side timer simply preforms a count-down and notifies the user when their session is about to expire.

The important thing to realize here is that the client-side and server-side scripts have no communication between each other nor is any needed other than when to start the count-down. The two scripts are separate, but are working in "apparent" concert. 

The server-side script will be the ultimate decider of IF the user's session has timed out or not. The client-side script only notifies the user of the count-down and nothing else.

HTH's

tedd

PS: Arby's?

_____________________
tedd@xxxxxxxxxxxx
http://sperling.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux