gpt4 book ai didi

All post request in laravel is saying 419 session expired(Laravel中的所有POST请求都表明419会话已过期)

转载 作者:bug小助手 更新时间:2023-10-25 19:30:57 31 4
gpt4 key购买 nike



the thing is that the project is working before.. then all of sudden i started seeing 419 on all my post request and i have @csrf on all my forms too

问题是,这个项目以前是有效的..然后突然我开始在我的所有帖子请求上看到419,我的所有表格上也都有@CSRF


                        <form method="POST" action="{{ route('login') }}">
@csrf
<div class="form_title pb-2">
<h4>@lang('Login Here')</h4>
</div>
<div class="mb-4">
<input class="form-control" type="text" name="username" value="{{old('username')}}" placeholder="@lang('Email Or Username')">
@error('username')<p class="text-danger mt-1">@lang($message)</p>@enderror
@error('email')<p class="text-danger mt-1">@lang($message)</p>@enderror
</div>

更多回答

When the form is rendered, can you check by inspecting the form from the source code that csrf field is really present?

当呈现表单时,您是否可以通过检查源代码中的表单来检查CSRF字段是否确实存在?

优秀答案推荐

Yes, the first case is you have to add @csrf field, which you have already done.

是的,第一种情况是您必须添加@CSRF字段,您已经这样做了。


First try running php artisan cache:clear

首先尝试运行php artisan缓存:Clear


Try this if you are on localhost

如果您使用的是本地主机,请尝试此操作


SESSION_DOMAIN=

In config/session.php

在配置/会话.php中


'domain' => env('SESSION_DOMAIN', ''),

Or if you're on server

或者如果您在服务器上


 SESSION_DOMAIN=mydomain.com 

In config/session.php

在配置/会话.php中


'domain' => env('SESSION_DOMAIN', 'mydomain.com'),

And don't forget running.

别忘了跑步。


php artisan cache:clear or php artisan optimize


Reference
Post request in Laravel - Error - 419 Sorry, your session/ 419 your page has expired




Allow your url in VerifyCsrfToken which is inside middleware.For example, if your url is /login then write in VerifyCsrfToken file something like below:

允许您的url在中间件内部的VerifyCsrfToken中。例如,如果您的url是/LOGIN,则在VerifyCsrfToken文件中写入类似以下内容:


protected $except = [
'login'
];

更多回答

Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, can you edit your answer to include an explanation of what you're doing and why you believe it is the best approach?

请记住,Stack Overflow不仅仅是为了解决眼前的问题,也是为了帮助未来的读者找到类似问题的解决方案,这需要理解底层代码。这对于我们社区的初学者和不熟悉语法的成员来说尤其重要。考虑到这一点,你能编辑你的答案,包括你正在做的事情的解释以及为什么你认为这是最好的方法吗?

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com