Warning:
The way $_REQUEST is populated by default can lead to strange bugs because of the unfortunate default setting of the configuration directive 'variables_order'.
Example: In an e-shop you want to display prices based on user preference. User can either switch the currency or the previous selection is used. By defaut, the following code WILL NOT WORK as expected:
<?php
if ($_REQUEST['currency']) {
$currency = $_REQUEST['currency']; setcookie('currency', $_REQUEST['currency'], 0, 'eshop.php'); }
else {
$currency = 'USD';
}
echo 'All prices are shown in ', $currency;
echo '<a href="eshop.php?currency=USD">Switch to USD</a>';
echo '<a href="eshop.php?currency=EUR">Switch to EUR</a>';
?>
Regardless of the user choice, the cookie value is used, so unless you change the default 'request_order' or 'variables_order' the $_REQUEST[something] variable is stuck with the cookie value forever regardless of the user 'REQUEST'.
Fix 1:
<?php
ini_set('request_order', 'CGP'); .
.
.
?>
Fix 2:
Be very careful and patient and go with $_GET, $_POST and $_COOKIE instead of the convenient $_REQUEST. Good luck.