What are the best practices for configuring session cookies in PHP to prevent security vulnerabilities?

Session cookies in PHP should be configured securely to prevent security vulnerabilities such as session hijacking or session fixation attacks. To enhance the security of session cookies, it is recommended to set the 'HttpOnly' and 'Secure' flags on the cookie. The 'HttpOnly' flag ensures that the cookie is only accessible through HTTP requests, making it more difficult for malicious scripts to access the cookie. The 'Secure' flag restricts the cookie to be sent only over HTTPS connections, preventing it from being transmitted over insecure channels.

// Configure session cookie settings
ini_set('session.cookie_httponly', 1);
ini_set('session.cookie_secure', 1);