How can session timeout settings impact the security of a PHP website?

Session timeout settings impact the security of a PHP website by determining how long a user's session remains active. If the session timeout is too long, it increases the risk of unauthorized access to the user's account if the session is hijacked. On the other hand, if the session timeout is too short, it may inconvenience users by forcing them to log in frequently.

// Set session timeout to 30 minutes
ini_set('session.gc_maxlifetime', 1800);
session_set_cookie_params(1800);
session_start();