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

旧时模样 提交于 2020-01-21 11:15:06

问题


Hello i am using laravel 5.7.15 i am facing issue

<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: ex@abc.xyz">
<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 csrf verification form kernal.php then session not work Any Help thanks in advance ..


回答1:


  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 CSRF you have the web middleware group wrapping your routes;

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




回答2:


Try to put @csrf in bottom of <form> tag




回答3:


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




回答4:


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




回答5:


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 @csrf after tag.




回答6:


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.

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

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

];



回答7:


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

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



回答8:


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 :)



来源:https://stackoverflow.com/questions/53609222/laravel-5-7-15-419-sorry-your-session-has-expired-please-refresh-and-try-again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!