In my config file i have "csrf_autoload" set to auto and my form have hidden csrf token field. But on submitt i got error "CSRF validation failed, Possible hacking attempt detected!". What am i missing?
You are sure $_POST contains the hidden csrf token field? And you are not checking manually as well (because that will invalidate the token)? Having multiple windows with forms open?
You use Security::generate_token(), which just generates a random token. It doesn't have anything to do with csrf checking. You need to use Security::fetch_token() instead.
I had a similar problem where I set "csrf_autoload" to true and while also manually checking with "Security::check_token()." Thanks to this post I was able to solve that small bug. But I don't see it clearly stated in the documentation.
Checking the token invalidates and rotates the current token, so you can check only once. If you do both, you end up with invalid token errors all the time.