CodeIgniter Forums
CSRF Token Didn't Match - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CSRF Token Didn't Match (/showthread.php?tid=72226)



CSRF Token Didn't Match - andhika - 11-24-2018

I need help, i activating csrf protection, but i have test with create a form search, always get these error "The action you have requested is not allowed." every the second submit, and i after check csrf token in html code did not match with have entered the browser.

<input type="hidden" name="'.$this->security->get_csrf_token_name().'" value="'.$this->security->get_csrf_hash().'">

I using CodeIgniter v3.1.9


RE: CSRF Token Didn't Match - jreklund - 11-25-2018

Are you submitting it with AJAX?

Then you need to return a new key from the server and update the html form after submitting. There are some threads here about that. But personally I have disabled CSRF re-generation. So I keep the same CSRF-key for the user.