What are the best practices for managing session lifetime in PHP?
To manage session lifetime in PHP, it is important to set the session cookie lifetime and the session garbage collection probability appropriately. This helps in controlling how long a session remains active and when it should be considered expired.
// Set session cookie lifetime to 1 hour
ini_set('session.cookie_lifetime', 3600);
// Set session garbage collection probability to 1%
ini_set('session.gc_probability', 1);
Keywords
Related Questions
- How can PHP be used to ensure that different pages with different IDs are included correctly?
- What resources are available for PHP beginners to improve their skills and knowledge?
- How can debugging techniques be utilized to troubleshoot and resolve issues related to variable manipulation in PHP code?