Long query strings get cut off when using Apache with Suhosin module enabled
Friday, November 27th, 2009Sometimes your query string can get veeeeery long due to having a big number of $_GET parameters in it. And what you might have noticed that sometimes your long query strings get cut off so not all the $_GET parameters that you put in it appear in the browser’s address bar. “What’s up with that ?” … you may think.
There could be a number of reasons and one of them is the topic of this post. Suhosin - an Apache module that put all sorts of checks and traps into your server functionality to catch nasty attempts to exploit the site. Sometimes, though, it may cause unwanted effects like the one described in the subject. If you are experiencing the symptoms described in the first paragraph check your server installation and, specifically, Suhosin module. By default, Suhosin is set to only allow query strings with no more than 200 parameters. So, if it is longer, it will get shortened to that set length. If you require longer than that query strings, you can change Suhosin’s settings in your php.ini. Look for the following lines:
suhosin.post.max_vars = 200
suhosin.request.max_vars = 200
… and change the numbers to higher ones. Easy.
Just a little notice though: make sure that you are using $_GET for getting, not for posting. Instead, maybe your better solution would be to use $_POST instead of $_GET.