Amir Hossein
Amir Hossein

Reputation: 1144

Can't set session manually

I'm new in Laravel 5.8 and I need to set a session manually I use this code Session::set('subset', 'yes'); but I get error how to set session manually in Laravel 5.8

Upvotes: 0

Views: 210

Answers (2)

Jithesh Jose
Jithesh Jose

Reputation: 1814

Set the session variable with value as follows..

 Session::put('key','value');

Retrieve value using

In controller

 $value = Session::get('key');

In view

 {{Session::get('key')}}

Upvotes: 1

sn n
sn n

Reputation: 399

You can use the global session helper which is available in laravel 5.8.

Set session simply by using

session(['key' => 'value']);

Retrieve session using

$value = session('key');

Upvotes: 0

Related Questions