Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ajax and CSRF
  • Hi all, ive read some discussions regarding fuel and csrf protection. Mostly it's working fine, but am I right in understanding that csrf and ajax do currently not mix well? I have a form where I do some api calls, lets say a delete button. Obviously after the first ajax submit the csrf token is invalid. I suppose I could return a new csrf token in the ajax response, but I have very limited options regarding modifications to the api client.

    Currently id be happy enough if the check_token() function did not actually invalidate the csrf token. I guess I could extend the security class and make a 'get_token' and do it that way, but am I overlooking something?

    Regards,

    Cor
  • HarroHarro
    Accepted Answer
    If you use ajax, you'll have to use http://docs.fuelphp.com/classes/security.html#/method_js_set_token

    It will make sure the crsf token stored in the form is correct.
  • Argh, i was playing around with that function but thought it was a one-off. I forgot cookies get passed back through ajax. thanks.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion