Answer the question
In order to leave comments, you need to log in
Why can't I set a new value in the session in the middleware?
Why doesn't the middleware set a new value in the session? The middleware itself is in the global middleware group:
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\MyMiddleware::class,
];
// \App\Http\Middleware\MyMiddleware.php
public function handle($request, Closure $next)
{
session()->put('last_request_time', time());
return $next($request);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question