简体   繁体   English

如何在 Laravel 5.3 中设置会话

[英]How to set sessions in Laravel 5.3

I am trying to use sessions in Laravel PHP我正在尝试在 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;我使用类像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?它在说什么,我该如何解决?

You should use put() or push() methods.您应该使用put()push()方法。 Or just use the session() helper.或者只使用session()助手。 Set the data:设置数据:

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

Get the data:获取数据:

session('store_id');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM