Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter CSRF question

I'm just wondering of there is any option where i can turn off CSRF in a specific controller/method. I've got another site that pings my site, but getting blocked because of the CSRF.

Is there any way i can get around this?

like image 906
LailaSweden Avatar asked Sep 22 '11 00:09

LailaSweden


People also ask

Why we use CSRF token in CodeIgniter?

Token Method There are several ways to do this, but in CodeIgniter hidden field is used which is called CSRF token. The CSRF token is a random value that changes with every HTTP request sent. When CSRF token is inserted in the website form, it also gets saved in the user's session.


1 Answers

Create a pre_system hook then put the following code inside your hook controller:

if(stripos($_SERVER["REQUEST_URI"],'/controller/function') !== FALSE)
{
    $CFG =& load_class('Config', 'core');
    $CFG->set_item('csrf_protection', FALSE);
}

Reference: http://codeigniter.com/forums/viewreply/869900/

like image 152
zgosalvez Avatar answered Sep 22 '22 12:09

zgosalvez