I have a yii (php) project and now I want to test, if it is safe against csrf attacks.
The code looks like this:
if (!Yii::app()->request->isAjaxRequest)){
die("error");
} else {
// Do stuff
}
Now, if I call the URL in Firebug, It works ("Do stuff" is executed).
$.get("example.com/foo", function(data){
// Works - no error
});
But, if I call the exact same URL in my Browser, I get "error", since Yii::app()->request->isAjaxRequest will be false.
Does that mean, my application is safe against CSRF attacks or is there any way to trick the "Yii::app()->request->isAjaxRequest" into thinking its an real Ajax-Request?
Thank you very much!