mattyvx Posted November 22, 2009 Share Posted November 22, 2009 Hi, I've create a script where users can log into my site and then edit their details, the updated details are then stored to my database. The users sessions are opened so the user can update their profile information and then log out. This time should be no longer than 2 hours. Currently im opening the session with session_start(); if((!isset($_SESSION['Email'])) || (!isset($_SESSION['Password']))){ header("location:login.php"); exit; } The questions are; 1) Should i set a path for these sessions to be stored? 2) How can I set an expirey time on these sessions i.e. 2 hours max Thanks in advance Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/ Share on other sites More sharing options...
Garethp Posted November 22, 2009 Share Posted November 22, 2009 1) No 2) When you login, set $_SESSION['Logintime'] = time(); Then at the top of every page, under session_start(); if(isset($_SESSION['Logintime']) && ($_SESSION['Logintime'] - time()) > 7200) { //Logout } Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/#findComment-963543 Share on other sites More sharing options...
mattyvx Posted November 23, 2009 Author Share Posted November 23, 2009 great, I take the time variable (7200) is in seconds... So if i implement this, with session_destroy(); in the "//logout " part of the script will this remove the session completely? I don't want a build up of unused and uneeded session files on my server. Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/#findComment-963554 Share on other sites More sharing options...
Garethp Posted November 23, 2009 Share Posted November 23, 2009 Pretty much, yeah. But Sessions are automatically destroyed if they go unused for a certain period of time, or if a person closes their browser Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/#findComment-963559 Share on other sites More sharing options...
mattyvx Posted November 23, 2009 Author Share Posted November 23, 2009 thanks for your help, oh and 10/10 for the new look site..... any ideas how to mark as topic solved? Its moved!!! Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/#findComment-963572 Share on other sites More sharing options...
Garethp Posted November 23, 2009 Share Posted November 23, 2009 When they upgraded, they lost the topic solved mod, and it's yet to be reimplemented Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/#findComment-963576 Share on other sites More sharing options...
mattyvx Posted November 23, 2009 Author Share Posted November 23, 2009 open forever muhahah! Well when it comes back. This topic is SOLVEDSVILLE! Link to comment https://forums.phpfreaks.com/topic/182557-php-sessions/#findComment-963580 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.