While creating the configuration products in Magento2.2.2 I am facing the

Invalid Form Key. Please refresh the page

error. I have google regarding this error and I have found the solution to

Increase the value of max_input_vars PHP configurable variable

I have increased this value but the problem is not solved.

While creating the configurable product almost 40000 associated product is generated and now I have set the max_input_vars value to 3075000 but the problem is not solved.

Anyone, please help me to fix this issue.

  • Then clear browser cache. Especially clear or delete cookies. Commented Jul 11, 2019 at 8:41
  • Try in private window
    – Mohit Rane
    Commented Jul 11, 2019 at 8:42
  • I have already tried this cache clear and private windows. Even I have tried from another computer but problem not solved.
    – Narayan
    Commented Jul 11, 2019 at 9:02
  • try restarting the apache server and then check again
    – surbhi agr
    Commented Jul 11, 2019 at 9:05
  • @surbhiagr I have tried with restart the apache & mysql also. But same problem.
    – Narayan
    Commented Jul 11, 2019 at 9:41

3 Answers 3


If Linux (Fedora) go to

sudo vi /etc/php.ini

Change memory_limit = 128M to 2040M

check session.gc_maxlifetime if its commented like


then change to

session.gc_maxlifetime = 1440

after that restart your apache server

sudo service httpd restart

Please check with below possibilities :

1 check with php info max_input_vars are updated or not. may be if you are using multiple php versions, so you assign value to another php.ini also please verify below values :

2 check with your database table core_config_data find path=web/cookie/cookie_domain, if you find row than remove it.

I hope its work for you.

  • yes all the php configuration updated correctly. check the setting here i.imgur.com/6UB1vzE.png. I have already tried this cookie setting before its empty (no records in Db) I have added a record and check again but its not working. then I have reverted by deleting the records
    – Narayan
    Commented Jul 16, 2019 at 9:53

Issue has been resolved by changing the PHP settings.

max_input_vars = 100000
max_input_nesting_level = 800
max_input_time = 18000

Reference :Php max_input_vars prevents attribute options saving in M2

Then run command

if Linux (Debian/Ubuntu):

sudo service apache2 restart
sudo /etc/init.d/apache2 restart
  • max_input_vars & max_input_time I have already set this to maximum. But I don't think we have to increase the max_input_nesting_level to 800. Now it is 64. Can you please tell me why should I increase this as I think 64 level is sufficient.
    – Narayan
    Commented Jul 18, 2019 at 6:19
  • @Narayan you can contact your server team they are given you perfect number Commented Jul 18, 2019 at 6:26
  • Yes I will thanks!
    – Narayan
    Commented Jul 18, 2019 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.