Welcome Guest, Not a member yet? Register   Sign In
Ajax - CSRF
#5

[eluser]Ondrej[/eluser]
[quote author="InsiteFX" date="1309968649"]I think there is another post here on the forums that shows how to do it using a hidden form field.

Code:
<input type="hidden" name="<?php echo $this->security->csrf_token_name?>" value="<?php echo $this->security->csrf_hash?>" />

InsiteFX[/quote]

Thanks, that did trick; however, I checked Security library and both properties are protected, but there are accessor methods which do the job.

I did this:

Code:
<input type="hidden" value="<?php echo $this->security->get_csrf_hash() ?>" id="csrf_protection" />

And the array I sent through jQuery:

Code:
var ajaxPostData = {
    "type": "news",
    "title": postTitle,
    "ci_csrf_token": $("#csrf_protection").val()                
};

Thanks a lot for help, I'm out.

Ondrej


Messages In This Thread
Ajax - CSRF - by El Forum - 07-05-2011, 01:00 PM
Ajax - CSRF - by El Forum - 07-05-2011, 04:35 PM
Ajax - CSRF - by El Forum - 07-06-2011, 01:53 AM
Ajax - CSRF - by El Forum - 07-06-2011, 05:10 AM
Ajax - CSRF - by El Forum - 07-06-2011, 05:41 AM
Ajax - CSRF - by El Forum - 07-06-2011, 06:19 AM
Ajax - CSRF - by El Forum - 07-06-2011, 07:04 AM
Ajax - CSRF - by El Forum - 07-30-2011, 12:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB