Is it possible to change max_input_vars in runtime?

codeigniter, forms, input, php

Solution

No, it's not possible to change it at runtime.

This is because at runtime the input has been already processed.

So the setting either resulted in an error already or it is too late to change it.

This is also documented in the manual as it lists places where you can change ini directives:

- Where a configuration setting may be set PHP DOCS

If you're unsure where all those places to change PHP configuration are and how to use them, there is another page in that section:

- How to change configuration settings PHP DOCS

Problem

Having an issue with number of form elements in a huge form. Some elements arent included in the post. After some searching I saw this: $_POST max array size ``` $this->input->post('formelement') uses max_input_vars as limiter. ``` Answer from link above is ok. I understand that I have to use `max_input_vars` in php.ini. That's ok locally, but if my webhosting company for my production server doesn't allow me to change this settings on their server - this is not an option. I'm using codeIgniter and creating a form like this: ``` <?php $attributes = array('id' => 'id of form'); echo form_open('controller/function-name', $attributes); //actual form content echo form_close(); ?> ``` After some further reading I understand that I could use `http://input` for bypassing this max_input_var limit. I could get the raw data output by doing this in `controller/function-name` ``` $postdata = file_get_contents("php://input"); ``` But then I would have to do things manually checking csrf-values etc, populating postdata, exploding it correctly etc etc.... I've also tried this in htaccess: (based on max_input_vars limited in PHP 5.2.17) ``` RewriteEngine On RewriteBase / php_value max_input_vars 6000 php_value suhosin.post.max_vars 6000 php_value suhosin.request.max_vars 6000 RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] ``` but then webpage is not accesible and I'm getting an internal error. The server I'm trying to make the change on is using `PHP Version 5.5.7-1+sury.org~precise+1` Is it possible to change `max_input_vars` in runtime (or am I doing something wrong with htaccess?)

Original source

Related problems