Symfony的1.4:在会话中存储的setAttribute与数组 [英] Symfony 1.4: Storing an array in session with SetAttribute
本文介绍了Symfony的1.4:在会话中存储的setAttribute与数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道是否有人知道如何数组存储到用户会话?
I'm wondering if someone knows how to store an array into a user session?
这是存储单个属性的方法:
This is the method to store a single attribute:
$this->getUser()->setAttribute('something', $something);
和文档说:
的用户属性可以存储任何类型的数据(字符串,数组和关联数组)的的
...但没有多说什么。 API文档不具有SetAttributes或一些类似的明显。
... but doesn't say anything more. The API documentation doesn't have a "SetAttributes" or something similarly obvious.
感谢您。
推荐答案
呃,因为我写的问题了,很明显:
Uh, as I'd written the question out, it became obvious:
$something = array();
$this->getUser()->setAttribute('something', $something);
解决。
这篇关于Symfony的1.4:在会话中存储的setAttribute与数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文