这个问题与上面的说明完全一样。我有这样的代码:
// These attributes are getting deleted for some reason
$this->session->set('userProfiles',new ArrayCollection($uniqueList));
// Get array filter and save it in session
$this->session->set('filter',$filter);
// Save session
$this->session->save();
// The code bellow effects my attributes above. I don't know why that is.
$this->session->set('center',$center);
// If I comment the line bellow then attributes 'userProfile' and 'filter' do not get deleted
$this->session->save();
我非常困惑为什么$this->session->save();在设置了我的中心属性之后,实际上是在删除我的数据。Symfony没有任何类似的记录。这可能与垃圾收集有关,但我真的不知道。
您放入会话中的内容必须是可序列化的。ArrayCollection
似乎没有实现'Serializable
接口。
您可以在文档中了解更多关于PHP会话处理的信息:
当PHP关闭时,它将自动获取$_SESSION superglobal,序列化它,并使用会话保存处理程序。