How can cookies be disabled for PHP sessions to prevent unauthorized access?

To prevent unauthorized access to PHP sessions, cookies can be disabled by setting the session.use_cookies configuration option to 0 in the php.ini file or using the ini_set() function in your PHP script. This will ensure that session IDs are not passed through cookies, making it harder for unauthorized users to hijack sessions.

// Disable cookies for PHP sessions
ini_set('session.use_cookies', 0);