【发布时间】:2014-04-28 09:31:06
【问题描述】:
我是 symfony2 的新手,当我尝试以自定义表单验证 csrf 令牌时遇到问题,我的问题是“如何在控制器中验证 csrf 令牌?
在我看来,这是我的代码。
<form role="form" action="{{ path('default_select_city_check') }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token('default_select_city_check') }}">
...
</form>
这是我在控制器中的代码:
public function selectCityCheckAction(Request $request) {
// in this part, how can I compare the token value in the form with the token value in the session?
}
感谢您的帮助
【问题讨论】:
标签: forms validation symfony token csrf