This error “Invalid Form Key. Please Refresh the Page” occurs in Magento 2 because of the limited number of variables that can be used for a single function. The max_input_vars in the php.ini file is the directive that holds this value. By default, the value of max_input_vars is set to 1000.
To get rid of the issue "Invalid Form Key. Please Refresh the Page", you should raise the value of max_input_vars to something between 5000 to 10000. To do this, you need to edit the php.ini file.
Here is how you can do this.php -i | grep php.ini
sudo /etc/init.d/apache2
This will resolve the issue in all Magento versions (2.1, 2.2, 2.3, 2.4)
If you face any issue while fixing this error, then feel free to contact our support team for a quick fix.
Related Articles: