Skip to content

Instantly share code, notes, and snippets.

@vzool
Last active July 2, 2018 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vzool/87b13a3d0c8e168a3587 to your computer and use it in GitHub Desktop.
Save vzool/87b13a3d0c8e168a3587 to your computer and use it in GitHub Desktop.
CodeIgniter: ignore CSRF in many URIs
// Put those lines in application/config/config.php
$csrf_ignore = [
'/page1.html',
'/about.html'
];
$is_csrf_condition_met = true;
foreach($csrf_ignore as $ci){
if (strpos($_SERVER["REQUEST_URI"], $ci) !== FALSE) {
$is_csrf_condition_met = false;
break;
}
}
$config['csrf_protection'] = $is_csrf_condition_met;
@Narendraoms
Copy link

I want to remove like index/[:num] but its not working

@willydevloper
Copy link

Hello,
this is for controller function, i want to ignore API file means web service controller file all functions.
Like :- $config['csrf_exclude_uris'] = array('myapifilename/*');
please help me for this.

@juliustip
Copy link

For anyone looking at targeting list of links which can be grouped in arrays see my answer HERE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment