Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
562 views
in Technique[技术] by (71.8m points)

linux - PHP session timeout callback?

I'm running a PHP + APACHE + CENTOS Linux combination.

I have implemented a login & logout on the website.

My question is, how can I know when the php session has timed-out (User has closed his browser without logging-out)?

The reason is, I want perform some cleanups and/or database updates (calling another PHP) when the user has done any of the following: (1) LOGGED-OUT or (2) TIMED-OUT

My guess is that I would have to make use of Apache/Linux, right?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of detecting when the php session times out, you could create a script that will run at some semi regular interval (every 5 minutes say, using a crontab job most likely) that will log out/perform the clean up for anyone who hasn't been active in the last hour (or whatever your timeout value is) automatically. Just add a 'lastseen' to your user table.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...