What role does the "register_globals" setting play in the functionality of reading cookies in PHP scripts?

The "register_globals" setting in PHP determines whether or not variables in the global scope are automatically registered as global variables. If this setting is enabled, it can lead to security vulnerabilities, including the ability for attackers to manipulate variables, such as cookies, directly. To properly read cookies in PHP scripts and ensure security, it is recommended to disable the "register_globals" setting.

// Disable register_globals in PHP
ini_set('register_globals', 0);

// Now you can safely read cookies using $_COOKIE superglobal
$cookie_value = $_COOKIE['cookie_name'];