How to log user out due to inactivity

前端 未结 7 631
借酒劲吻你
借酒劲吻你 2021-01-01 04:21

Pure, server-side PHP. Every time a user submits a form, I update a \'last activity\' time in the database.

I want to make a periodic check and force logout inactiv

7条回答
  •  囚心锁ツ
    2021-01-01 04:46

    I want to make a periodic check and force logout inactive users to free up licenses

    I assume you meant.. When a session has (should have) expired, you need to 'do something' to free a license, and you want it controlled server-side.

    session.gc_maxlifetime hurts here because PHP does not send notification when it destroys a session.

    You need a cron job to scan the PHP session folder for sessions whose atime has exceeded your timeout and release their license (and also delete the session). A beginning for such a script is

    cd /path/to/sessions; find -cmin +24 | xargs rm

    which was taken from the bottom of http://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime You will replace the xargs rm with something more useful to you.

提交回复
热议问题