What best practices should be followed when setting up PHP session parameters to ensure optimal performance and security?

When setting up PHP session parameters, it is important to ensure both optimal performance and security. To achieve this, consider setting session.gc_probability and session.gc_divisor to lower values to decrease the likelihood of garbage collection running on every request. Additionally, use a secure session cookie by setting session.cookie_secure to true to only transmit session cookies over HTTPS.

// Set session garbage collection probability and divisor
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 100);

// Use secure session cookie
ini_set('session.cookie_secure', 1);