Jump to content

The CSRF token is invalid. Please try to resubmit the form.


stefano7

Recommended Posts

Hi,

i'm using prestashop in local with mamp. Later that i've imported attributes via csv in two product it gives me this error when i try to modify and the product:

  • The CSRF token is invalid. Please try to resubmit the form.

please anyone can help me?

 

 

Stefano

 

ps. sorry for my english

 

Prestashop 1.7.0.3

 

SERVER

Informazioni sul server: Darwin Darwin Kernel Version 15.6.0: Wed Nov 2 20:30:56 PDT 2016; root:xnu-3248.60.11.1.2~2/RELEASE_X86_64 x86_64

Versione software del server: Apache/2.2.31 (Unix) mod_wsgi/3.5 Python/2.7.12 PHP/7.0.12 mod_ssl/2.2.31 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0

Versione di PHP: 7.0.12

Limite di memoria: 128000M

Tempo di esecuzione massimo: 30000

Dimensione Max. dei file da caricare: 32M

Edited by stefano7 (see edit history)
Link to comment
Share on other sites

I can't offer much help other than saying I'm seeing similar. It's also affecting products I've imported so I perhaps that is a clue.

 

Looking at the source I am guessing the form element setting the CSRF is the hidden input id="form__token" - that has a long string in there so it's being set, but for some reason the server is expecting something different when hitting save.

 

Any good debugging tips would be welcome, I assumed it was a random string but if the problem is related to imported products I'm wondering if perhaps it's seeded with an attribute from the product which is getting skipped on import?

Link to comment
Share on other sites

I have done a bit more digging and can offer something of a solution now! Checking my logs I saw the error

PHP message: PHP Warning:  Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini.

So I increased max_input_vars and restarted php-fpm and voila, imported products can be saved again. I don't see an obvious reason why imported products need the higher allowance and 1000 already seems pretty generous, but it got things working for me.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

There are a number of ways to increase the max_input_vars setting for PHP and your hosting company may dictate how to do that, so if you get stuck search their knowledge base for PHP configuration settings. However the easiest method is probably to edit the .htaccess file in the root of your website and add the following line:

php_value max_input_vars 1000

1000 was the default for me, and I had to keep increasing it. I think I ended up at 16000 which is crazy really, but it was the only way to save new products.

Link to comment
Share on other sites

There are a number of ways to increase the max_input_vars setting for PHP and your hosting company may dictate how to do that, so if you get stuck search their knowledge base for PHP configuration settings. However the easiest method is probably to edit the .htaccess file in the root of your website and add the following line:

php_value max_input_vars 1000

1000 was the default for me, and I had to keep increasing it. I think I ended up at 16000 which is crazy really, but it was the only way to save new products.

 

Thank you. Sorry, but where is the ".htaccess file" ? I can't find the file

Link to comment
Share on other sites

Without more info about your platform it'll be hard to offer much more advice than the fact that you need to change a setting in your PHP config http://php.net/manual/en/configuration.changes.php

 

 

 

It's hard to say whether you can't find .htaccess because someone else installed the software for you and put the .htaccess contents into the server config (which is required on some servers and just good practise on the rest), or perhaps you're trying to view the filesystem through a tool that doesn't display hidden files by default and you've not used the argument to make them appear (ls -a on *nix CLI, probably a checkbox in GUI).

 

If you can share some info about what you've done so far it might be easier to narrow down your problem.

Link to comment
Share on other sites

  • 2 months later...
  • 2 years later...
On 3/21/2017 at 3:23 PM, caomhin said:

There are a number of ways to increase the max_input_vars setting for PHP and your hosting company may dictate how to do that, so if you get stuck search their knowledge base for PHP configuration settings. However the easiest method is probably to edit the .htaccess file in the root of your website and add the following line:


php_value max_input_vars 1000

1000 was the default for me, and I had to keep increasing it. I think I ended up at 16000 which is crazy really, but it was the only way to save new products.

Dont work for me. My prestashop returns 500 error when I update my .htaccess

 

Link to comment
Share on other sites

  • 1 year later...

J'ai le même soucis, mais si pour modifier l'article lui même je ne peux ni le modifier, ni le dupliquer, en revanche sur le menu (liste des produits) je peux le dupliquer . . . pour les informaticiens, là se trouve peut-être la solution . . . en copiant la séquence d'enregistrement du produit de la liste, sur la séquence du masque d'enregistrement de la fiche du produit . . . 

merci de dire si c'est la solution et si vous avez pu résoudre ce problème  .....

Gérard

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...