0

hi guys, just wanna ask, could you give me some code about session time out? i have a different page for login and index. any help would be very much appreciated.
thanks in advance ^^

3
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by __avd
0

session.gc_maxlifetime is based off of the last time a session file was modified. So every time a session file is modified or a session_start() is called in a separate page, the countdown to gc_maxlifetime begins a new and the user stays "logged in".

function my_session_start($timeout = 1024) {
        ini_set('session.gc_maxlifetime', $timeout);
        session_start();
        if (isset($_SESSION['timeout_idle']) && $_SESSION['timeout_idle'] < time()) {
            session_destroy();
            session_start();
            session_regenerate_id();
            $_SESSION = array();
        }
        $_SESSION['timeout_idle'] = time() + $timeout;
    }

Take a look at - http://php.net/session_start

Edited by __avd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.