[英]Laravel 5.4 Session not storing
I am trying to get a simple session to store a value but am having trouble saving it. 我试图通过一个简单的会话来存储值,但是在保存值时遇到了麻烦。 I have looked around at similar posts about this and tried their suggestions without any luck.
我到处浏览过类似的帖子,并在没有运气的情况下尝试了他们的建议。 Here is what I have done:
这是我所做的:
Use "web" in middlewareGroups 在中间件组中使用“ Web”
Route::group(['middlewareGroups' => ['web']], function() {
...
Use "web" in middleware and also manually 在中间件中使用“网络”,也可以手动使用
Route::group(['middleware' => ['web']], function() {
...
and 和
$this->middleware('web');
Used Session::put
, session()
global and $request->session()
and even $_SESSION
使用过的
Session::put
, session()
全局和$request->session()
甚至$_SESSION
Found this article and tried the answer but still nothing. 找到了这篇文章,并尝试了答案,但还是没有。 I am using files to store my sessions
我正在使用文件存储会话
Added the following to my Kernel.php 将以下内容添加到我的Kernel.php中
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Barryvdh\Cors\HandleCors::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class
];
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class
],
'api' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Session\Middleware\StartSession::class,
'throttle:60,1',
'bindings',
],
];
And yet nothing! 却什么都没有! Perhaps you guys can shed some light?
也许你们可以阐明一些想法? Many thanks.
非常感谢。
I was facing the same problem in Laravel 5.4 我在Laravel 5.4中面临相同的问题
I found that adding the save method solved the problem. 我发现添加save方法可以解决此问题。
Session::put('key', $value);
Session::save();
Hope it helps. 希望能帮助到你。 Cheers.
干杯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.