protected $middleware = [
\App\Http\Middleware\Syspoint::class,
]
use Session;
class Syspoint
{
echo \Session::get('syspoint');
}
I have a middleware required run everytime when page request, the middleware contain session.
I place inside of protected $middleware
, but global middleware not able to get session.
You are calling Session but it is not already started.
If you need Session inside your middleware you have to put it in the property protected $middlewareGroups
under the key web
and after the call to StartSession, i.e.:
protected $middlewareGroups
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\Syspoint::class,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With