Alex
Alex

Reputation: 133

How to set sessions in Laravel 5.3

I am trying to use sessions in Laravel PHP

I used this

Session::set('store_id', $store->store_id); Session::set('user_id', $store->id);

and used them like

Session::get('store_id')

I used class like use Session;

But I am getting error

FatalErrorException in Manager.php line 137: Call to undefined method Illuminate\Session\Store::set()

What is it saying and how do I resolve it?

Upvotes: 2

Views: 2586

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163978

You should use put() or push() methods. Or just use the session() helper. Set the data:

session(['store_id' => $store->store_id]);

Get the data:

session('store_id');

Upvotes: 2

Related Questions