Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make custom session timeout in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 163
    Comment on it

    Hello Reader's!, If you want to make the custom php session which will destroy automatic then you can use the code as below:-

    session_start(); // ready to go!
    
    $now = time();
    if (isset($_SESSION['discard_after']) && $now > $_SESSION['discard_after']) {
    
        session_unset();
        session_destroy();
        session_start();
    }
    

    Here either new or old, it should live at most for another hour

    this session has worn out its welcome. It will start a new one

    $_SESSION['discard_after'] = $now + 3600;
    

 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: