简体   繁体   English

Laravel在表单提交后使CSRF令牌或页面失效

[英]Laravel expire csrf token or page after form submission

My application has two forms to submit input to perform some transactions and calculation, I want to avoid from re-submission, how can I avoid that? 我的应用程序有两种形式来提交输入以执行一些事务和计算,我想避免重新提交,如何避免这种情况?

For eg if user tries to push history back button, he should not see the previous form instead should see page expire or auto redirection to 1st form. 例如,如果用户尝试向后推历史记录按钮,则他不应看到以前的表格,而应看到页面过期或自动重定向到第一表格。

Or how can I set page expiration in Laravel? 或者如何在Laravel中设置页面过期时间?

As csrf_token expiration do it after timeout and force user to go to 1st page or login page. 由于csrf_token到期,请在超时后执行此操作,并强制用户转到第一页或登录页面。

You can use the helper of laravel. 您可以使用laravel的助手。 Form::open(array('url' => 'foo/bar')) Form::close() 形式:: open(array('url'=>'foo / bar'))形式:: close()

In this case laravel will make csrf token instead of you and you will easily avoid of resubmit cases. 在这种情况下,laravel将代替您使用csrf令牌,您将很容易避免重新提交案例。 Also you can yourself make csrf token with this code: Form::token() 您也可以使用以下代码自行制作csrf令牌:Form :: token()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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