Welcome Guest, Not a member yet? Register   Sign In
Csrf not working sometimes
#3

(03-17-2023, 02:45 AM)captain-sensible Wrote: no idea but in a form this works for me :

Code:
<div class ="flex2">
<div class ="content">
<div class="d-flex justify-content-center">
      <?= form_open_multipart('newblog'); ?>
<?= csrf_field() ?>

then the controller that accepts the data from the form , check with:

Code:
$lucky= $this->request->getVar(csrf_token());

I noticed that you are using form_open function. If i'm not wrong, form open include automatically the csrf_field and in the controller it is not necessary to check for csrf validation because CI4 do it by itself. I've tried to set regeneration to false for now, just to test if the security exception happens again. The project is actually in use for work from my company and for now it seems to work but yesterday it did the same: working for all the day and in the evening pull out the security exception. I was thinking that the problem may be caused by 2 users logged in that do different posts action and update the csrf token value, but i'm not sure of it beacause with tests i can't reproduce the issue (even with 2 users). Waiting until the end of the day to check if the problem still occurs
Reply


Messages In This Thread
Csrf not working sometimes - by Uhrien - 03-16-2023, 08:37 AM
RE: Csrf not working sometimes - by Uhrien - 03-17-2023, 03:52 AM
RE: Csrf not working sometimes - by Uhrien - 03-17-2023, 07:30 AM
RE: Csrf not working sometimes - by kenjis - 03-17-2023, 07:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB