gpt4 book ai didi

session - Laravel session 存储未根据请求设置

转载 作者:行者123 更新时间:2023-12-02 14:20:22 25 4
gpt4 key购买 nike

我正在开发一个小型网站,并且在 session 方面遇到问题。当我尝试登录或进行 AJAX 调用时,出现以下 RuntimeException:

RuntimeException in Request.php line 758: Session store not set on request.

in Request.php line 758
at Request->session() in VerifyCsrfToken.php line 87
at VerifyCsrfToken->tokensMatch(object(Request)) in VerifyCsrfToken.php line 49
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Language.php line 38
at Language->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Language), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54

知道我做错了什么吗?提前致谢

最佳答案

看看@Cas Bloem 他的回答,这对我有惊人的帮助:

Laravel - Session store not set on request

这就是为什么它对我不起作用。因为您使用的 session 期望与 CSRF token 匹配(这是我最好的猜测,我自己是 Laravel 的新手)。

此外,如果您转到应用程序->http->中间件->VerifyCsrfToken,您可以将路由添加到不会检查 CSRF 验证的数组。再加上 Cas Bloem 的修复(将路由放在 paths.php 的不同部分)解决了我的问题。我现在只是在本地主机上开发/学习,但需要稍后实现。

希望这有助于/解决问题!

关于session - Laravel session 存储未根据请求设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33517763/

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