laravel 5.7.15 419 抱歉,您的会话已过期。请刷新并重试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53609222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:11:28  来源:igfitidea点击:

laravel 5.7.15 419 Sorry, your session has expired. Please refresh and try again

phplaravellaravel-5.7csrf-token

提问by Ijaz Ahmed Bhatti

Hello i am using laravel 5.7.15 i am facing issue enter image description here

您好,我正在使用 laravel 5.7.15 我遇到了问题 在此处输入图片说明

<form method="post" action="my_post_Action" class="login100-form validate-form">
<input type="hidden" name="_token" value="B6et9cJOP5wNKodCPgCbAafDjpA5EMcRaaJhEJ9F">
<span class="login100-form-title">
Admin Login
</span>
<div class="wrap-input100 validate-input" data-validate="Valid email is required: [email protected]">
<input class="input100" type="text" name="email" placeholder="Email">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-envelope" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<input class="input100" type="password" name="password" placeholder="Password">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-lock" aria-hidden="true"></i>
</span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn">
Login
</button>
</div>
</form>

here is my code i don't know whats error it my login route if i comment csrfverification form kernal.phpthen session not work Any Help thanks in advance ..

这是我的代码我不知道我的登录路径有什么错误如果我评论csrf验证表单kernal.php然后会话不起作用任何帮助提前致谢..

采纳答案by Ijaz Ahmed Bhatti

I do not really got the issue I have tried every solution but i have to install new Laravel and have to move all my Controllers, Routes, And views manually to get rid of the issue Really thanks to all of you guys:)

我并没有真正解决这个问题,我已经尝试了所有解决方案,但我必须安装新的 Laravel,并且必须手动移动我所有的控制器、路由和视图以解决这个问题真的感谢你们所有人:)

回答by Diogo Santo

  1. Make sure you hard refresh the page; Clear the cache as well by doing:

    php artisan cache:clear

  2. Make sure you have the right permissions for your logs folder:

    chmod -R 755 storage/logs

  3. Make sure to generate a key for your application:

    php artisan key:generate

  4. Check if, when using post and CSRFyou have the webmiddleware group wrapping your routes;

  1. 确保你硬刷新页面;通过执行以下操作清除缓存:

    php artisan 缓存:清除

  2. 确保您对日志文件夹具有正确的权限:

    chmod -R 755 存储/日志

  3. 确保为您的应用程序生成一个密钥:

    php工匠密钥:生成

  4. 检查在使用 post 和CSRF 时是否有web中间件组包装你的路由;

I solved mine with that! Hope it helps! :D

我用那个解决了我的!希望能帮助到你!:D

回答by Ryuujo

Try to put @csrfin bottom of <form>tag

尝试放在标签的@csrf底部<form>

回答by MD. Jubair Mizan

It's one time only? Just delete the folder storage/framework/cache/data

是不是只有一次?删除文件夹storage/framework/cache/data

回答by Péter

You have to set chmodto 757for ./storage/framework/sessionsalso. It helps for me and it works fine now, without error 419.

你必须设置chmod757./storage/framework/sessions也。它对我有帮助,现在工作正常,没有错误419

回答by Péter

Anytime you define an HTML form in your application, you should include a hidden CSRF token field in the form so that the CSRF protection middleware can validate the request. Try @csrfafter tag.

任何时候在应用程序中定义 HTML 表单时,都应该在表单中包含一个隐藏的 CSRF 令牌字段,以便 CSRF 保护中间件可以验证请求。@csrf标记后尝试。

回答by Sultanos

Just in case of dispair and when no other solution Works , you can add your page name here to a White list to the pages that will not be checked with CSRF.

以防万一,当没有其他解决方案有效时,您可以将您的页面名称添加到白名单中,这些页面将不会被 CSRF 检查

Needless to say , is a must to remember that with this you are removing this security check , use it wisely and at your own criteria

毋庸置疑,必须记住,通过此操作,您将删除此安全检查,请根据您自己的标准明智地使用它。

you can find it here : app/Http/Middleware/VerifyCsrfToken.php

你可以在这里找到它:app/Http/Middleware/VerifyCsrfToken.php

  /**
 * The URIs that should be excluded from CSRF verification.
 *
 * @var array
 */
protected $except = [
    '/nameofpagetobeexcluded','/anotherpagetobeexcludedfromthischeck'

];

回答by Arshad Jilani

Make sure you have added @csrfOR {{ csrf_field() }}in your form.

确保您在表单中添加了@csrf{{ csrf_field() }}

<form method="post" action="{{ url('your route here') }}">
  @csrf
 </form>