How can the session duration be reliably extended in PHP to prevent users from being logged out prematurely during an activity?
To extend the session duration in PHP, you can adjust the session cookie's expiration time to a longer period. This will prevent users from being logged out prematurely during an activity by ensuring that the session remains active for a longer period of time.
// Extend session duration to 1 hour
ini_set('session.gc_maxlifetime', 3600);
session_set_cookie_params(3600);
session_start();
Keywords
Related Questions
- What are some recommended tools or libraries for generating PDF files from user interactions in a web application using PHP and JavaScript?
- What are the potential pitfalls of using IP addresses as security tokens in PHP scripts, and how can they be avoided?
- What are the potential implications of having conflicting values for safe_mode in the master value and local value columns in phpinfo?