简体   繁体   中英

csrf chack with phalcon php and angular

I am using Phalcon PHP with angular JS, and I have a form with toke hidden input:

<input type="hidden" name="{{ security.getTokenKey() }}" value="{{ security.getToken() }}" >

I submit the form with ng-submit . In the controller, I did:

$post   =   $this->request->getJsonRawBody();

foreach($post as $postName => $postValue) {
   $_POST[$postName]   =   $postValue;
}
if($post && $this->security->checkToken())  {

}

But the check token return false. Anyone have any idea??

thx

Did you add a session adapter to your Dependency Injector?

$di->setShared('session', function() {
    $session = new Phalcon\Session\Adapter\Files();
    $session->start();
    return $session;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM