Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to destroy user session automatically in PHP if he don't log out

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 440
    Comment on it

    Hello Reader's! If you have to destroy or unset the user's session automatic then the better way is to set with time dependency

    session_start();
    if (!isset($_SESSION['EXPIRES']) || $_SESSION['EXPIRES'] < time()+1800) {
        session_destroy();
        $_SESSION = array();
    }
    $_SESSION['EXPIRES'] = time() + 1800;
    

    Now As the example above the session is set to destroy within 1800 sec.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: