Kez323 Posted August 15, 2013 Share Posted August 15, 2013 this expire system wont work.. whats wrong with it? When you login: (login page) <?php session_start(); $_SESSION['start'] = time(); $_SESSION['expire'] = $_SESSION['start'] + (3600); ?> The page you goto after you login: (logged in page) <?php session_start(); $now = time(); if($now > $_SESSION['expire']) { session_destroy(); echo "session expired!"; } else { echo $myusername; } ?> When im at the logged in page, and i refresh it just says "session expired!" Quote Link to comment https://forums.phpfreaks.com/topic/281208-php-login-expire-sessions/ Share on other sites More sharing options...
Solution .josh Posted August 15, 2013 Solution Share Posted August 15, 2013 You have some whitespace before your opening <?php tag which should have given you a warning.. this may possibly be causing $_SESSION['expire'] to be unavailable on the logged in page (depending on some other settings), so try removing it. But other than that, at face value, the script works fine by itself.. Quote Link to comment https://forums.phpfreaks.com/topic/281208-php-login-expire-sessions/#findComment-1445203 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.