// check CSRF protection in a controller action public function myAction(sfWebRequest $request) { // check CSRF protection $request->checkCSRFProtection(); // continue with the action logic // ... }
// enable CSRF protection in a form class MyForm extends sfForm { public function configure() { // enable CSRF protection $this->widgetSchema->setFormFormatterName('list'); $this->setWidget('csrf_token', new sfWidgetFormInputHidden()); $this->setValidator('csrf_token', new sfValidatorCSRF(array('required' => true))); // add other form fields and validators // ... } }In these examples, the package library is Symfony PHP framework.