![]() |
I am trying to get data for ajax datatable using the post method
Code: 'ajax': { the error I am facing is attached below Code: {title: "CodeIgniter\Security\Exceptions\SecurityException",…} but token hash is being sent Code: data[csrf_token_name]: f57a4b1efb1e46b0fa37c1bc7fe38d46 Please lemme know if this is a bug or if I am doing anything wrong here, I have done lotta work with csrf in 4.19, IDK why it is acting differently here. Thanks in advance.
You are sending the hash in a nested array, but it must be contained in the top one.
You send [ 'data' => ['csrf_token_name' => '....']] But expected [ 'data' => [], 'csrf_token_name' => '....'] In any case, you can send the hash in the header. (06-04-2022, 08:57 AM)iRedds Wrote: You are sending the hash in a nested array, but it must be contained in the top one. PHP Code: Array
If you look at the code that extracts the hash of the token, you will see that the hash is not looked up in nested arrays.
So if you didn't get any errors, then your CSRF protection wasn't working. https://github.com/codeigniter4/CodeIgni...#L321-L338 PHP Code: private function getPostedToken(RequestInterface $request): ?string (06-04-2022, 09:25 AM)SubrataJ Wrote:Thanks, it works now.(06-04-2022, 08:57 AM)iRedds Wrote: You are sending the hash in a nested array, but it must be contained in the top one. |
Welcome Guest, Not a member yet? Register Sign In |