XF 2.1 How can I disable the CSRF protection?

researcher

Member
Licensed customer
Hey, how are you?
I have just created a page in XF but while I am trying to send a POST request, I get this error:
Security error occurred. Please press back, refresh the page, and try again.

I think this error causes because of CSRF protection. How can I disable the CSRF protection in my custom page? (I have PHP callback)

Thanks.
 
How can I add token-control in my script? Normally I can write a anti-csrf function for PHP but I dont know that how can I do this in XF.
Simply don't do that. Instead fix your code to properly include the token.
 
I was running on /forum/pages/xxxx --- and I have just solved.
PHP:
$csrftoken = \XF::app()->get('csrf.token');
echo '<input type="hidden" name="_xfToken" value="'.$csrftoken.'">';

just add $csrftoken in your form with "_xfToken" name.

Where are you generating POST - outside of XenForo?
Do you have access to the cookies?
 
Back
Top Bottom