Skip to content

Instantly share code, notes, and snippets.

@sfengyuan
Forked from vzool/config.php
Created January 31, 2016 11:50
Show Gist options
  • Save sfengyuan/2a77538ed1a5c4aec41c to your computer and use it in GitHub Desktop.
Save sfengyuan/2a77538ed1a5c4aec41c 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment