How to detect if a user has logged out, in php?

后端 未结 12 2486
南笙
南笙 2020-12-06 02:19

After the user successfully logs in, I store login = true in database. But how do I check if the user logged out by closing the browser without clicking the logout button? A

12条回答
  •  心在旅途
    2020-12-06 03:08

    Normally you would put such information in sessions.

    $_SESSION['user'] = "A user name";
    

    Then when you want to logout you do:

    session_destroy();
    

    Some more info on sessions here and a tutorial.

提交回复
热议问题