2

I'm working in codeigniter v3 and i got error when i use CSRF token while working with REST API in postman error looks like this..

enter image description here

Can anybody help me with this. Also i want to disable CSRF protection for several urls. I tried to achieve this by placing the url in

$config['csrf_exclude_uris'] = array('webservice');

but it still not working.

1 Answer 1

2

You need to specify the full uri like this:

$config['csrf_exclude_uris'] = array(
    'webservice/addCandidate'
);

Or with regex :

$config['csrf_exclude_uris'] = array(
    'webservice/[a-zA-Z]+'
);
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you mate, how can i disable this in such urls like coderevision.com/candidate/addCertificates/1 means that contains numbers as a parameter. please give me a solution for that also.
@poojanmehtaPM You're welcome, regex for number : [0-9]+ Example : webservice/[a-zA-Z]+/[0-9]+
Thank you @Maxime D, can you please tell me how can i know that, disable is working or not because i can still see csrf hidden field code in browser html.
@poojanmehtaPM delete your cookie
i deleted the cookie but i can still see the csrf field in browser. :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.