Skip to content

Instantly share code, notes, and snippets.

@wmandai
Created January 4, 2014 12:15
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wmandai/8254861 to your computer and use it in GitHub Desktop.
Save wmandai/8254861 to your computer and use it in GitHub Desktop.
Codeigniter disable CSRF in specific pages
<?php
// Add this to your config.php file
if (stripos($_SERVER["REQUEST_URI"],'/controller/method') === FALSE) {
$config['csrf_protection'] = TRUE;
}else{
$config['csrf_protection'] = FALSE;
}
//the rest of the code
@tanmaybug
Copy link

You can also use,
$config['csrf_exclude_uris'] = array('controller/method');

@willydevloper
Copy link

Hello,
this is for controller function, i want to ignore API file means web service controller file all functions.
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

@saparovkutman
Copy link

Thank you

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