Extend Session Logout Time
![Ben](https://flatboard.org/uploads/avatars/generates/6cb01ce90x50dot.png)
Extend Session Logout Time
Ben@84171e7c Monday 24th July 2023, 16:58:55If you find yourself needing to login in too frequently, here's how to extend this.
To change the session timeout to a longer period of time (e.g., 2 hours) before automatically logging out, you need to set the session.gc_maxlifetime value using the ini_set() function.
Before you start, first make a backup of the header.php file.
Then you can modify the header.php file as shown:
Open the header.php file in the root folder of your Flatboard install with a text or code editor.
Locate the section where session_start() is called. It looks like this:
Then you need to add the following code above the session_start() function line to set the session timeout to 2 hours:
Save your changes and now forum users will stay logged in for 2 hours of inactivity before being automatically logged out.
The 120 session timeout can be changed to fit your preference. Multiply the number of hours you want your session to last by 60 and replace 120 with this number. Don't set it for too long as this can pose a security risk.
To change the session timeout to a longer period of time (e.g., 2 hours) before automatically logging out, you need to set the session.gc_maxlifetime value using the ini_set() function.
Before you start, first make a backup of the header.php file.
Then you can modify the header.php file as shown:
Open the header.php file in the root folder of your Flatboard install with a text or code editor.
Locate the section where session_start() is called. It looks like this:
if (!session_id()) session_start();
$token = CSRF::generate();
Then you need to add the following code above the session_start() function line to set the session timeout to 2 hours:
// Set the session timeout to 2 hours (120 seconds)
$sessionTimeoutSeconds = 120;
// Set the session.gc_maxlifetime configuration option using ini_set()
ini_set('session.gc_maxlifetime', $sessionTimeoutSeconds);
Save your changes and now forum users will stay logged in for 2 hours of inactivity before being automatically logged out.
The 120 session timeout can be changed to fit your preference. Multiply the number of hours you want your session to last by 60 and replace 120 with this number. Don't set it for too long as this can pose a security risk.
Reply 1
![SurveyBuilder-Admin](https://flatboard.org/uploads/avatars/SurveyBuilder-Admin_58600212.png)
That would be great, but certain server hosting disallows ini_set functions.
Software engineer, creates plugins for Flatboard, checks source codes, and answers any software errors questions and contributes on the GitHub page as well
Suggested Topics
![simon](https://flatboard.org/uploads/avatars/simon_20a65f4f.png)
Simon
started solved MUST READ BEFORE INSTALLING FLATBOARD!!
Announcements
![](https://flatboard.org/uploads/avatars/generates/ab25285f0x50dot.png)
Alexander
started solved Error 500 on the index page after Update to Flatboard 2.0
Bug reports
![Fred](https://flatboard.org/uploads/avatars/Fred_4346f29d.png)
Fred
started plugin SnowFlakes
Resources
![](https://flatboard.org/uploads/avatars/generates/d0bcf8bbdx50dot.png)
nootkan
started Update Issues
General Questions