How to implement thinkphp background detection of user login timeout

WBOY
Release: 2016-07-25 09:05:33
Original
1712 people have browsed it
  1. class CommAction extends Action {
  2. public function __construct() {
  3. parent::__construct();
  4. $this->checkAdminSession();
  5. }
  6. public function checkAdminSession() {
  7. //Set the timeout to 10 minutes
  8. $nowtime = time();
  9. $s_time = $_SESSION['logintime'];
  10. if (($nowtime - $s_time) > 600) {
  11. unset($_SESSION[' logintime']);
  12. $this->error('The current user is not logged in or the login has timed out, please log in again', U('login/loginpage'));
  13. } else {
  14. $_SESSION['logintime'] = $nowtime;
  15. }
  16. }
  17. }
  18. ?>
Copy code

If it is a process-oriented program, write a session.inc.php, write the program judgment in this file, and then other files Just include it.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template