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 ^^

Recommended Answers

All 2 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.