Posting values from page to page through the URL is common place with PHP but some sites run the risk of bumping into a security policy, namely, the Suhoshin patch.
This patch applies a limit to GET values of 512 characters, resulting in the value simply being dropped.
The patch is there for good reason and posting values in URLs provides plenty to be nervous about but should you require increasing the permitted value or at least being able to get around the issue - here are a couple of approaches:
1. If you have access to PHP.ini and can edit, simply alter the suhosin.get.max_value_length limit to the required value.
2. If you cannot increase the permitted limit your $_GET needs to change very slightly and be preceded by with a small snippet:
Before:
<?php echo $_GET['foo'] ?>
After:
<?php
$qs = parseQueryString($_SERVER['QUERY_STRING']);
echo $qs['foo'];
?>
<?php
function parseQueryString($str) {
$op = array();
$pairs = explode("&", $str);
foreach ($pairs as $pair) {
list($k, $v) = array_map("urldecode", explode("=", $pair));
$op[$k] = $v;
}
return $op;
}
?>
It is great creation with better knowledge. Really helpful thing you have created.
ReplyDelete