Error 400: The CSRF token could not be verified

E

How Can We Help?

Error 400: The CSRF token could not be verified

Getting Error 400: The CSRF token could not be verified. when trying to delete an item using the default delete link.

$this->menu=array(
array(‘label’=>’Create Use’, ‘url’=>array(‘create’)),
array(‘label’=>’Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id)),
array(‘label’=>’Delete Use’, ‘url’=>’#’, ‘linkOptions’=>array(‘submit’=>array(‘delete’,’id’=>$model->use_id,’confirm’=>’Are you sure you want to delete this item?’)),
array(‘label’=>’Manage Uses’, ‘url’=>array(‘admin’)),
);

Answer:

This problem can be solved by adding ‘csrf’ => true to the linkOptions

$this->menu=array(
array(‘label’=>’Create Use’, ‘url’=>array(‘create’)),
array(‘label’=>’Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id)),
array(‘label’=>’Delete Use’, ‘url’=>’#’, ‘linkOptions’=>array(‘submit’=>array(‘delete’,’id’=>$model->use_id,’confirm’=>’Are you sure you want to delete this item?’),’csrf’=>true)),
array(‘label’=>’Manage Uses’, ‘url’=>array(‘admin’)),
);

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me