Symfony 1.4: Storing an array in session with SetAttribute

戏子无情 提交于 2019-12-22 08:26:02

问题


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);

And the documentation says:

"User attributes can store any type of data (strings, arrays, and associative arrays)"

... but doesn't say anything more. The API documentation doesn't have a "SetAttributes" or something similarly obvious.

Thank you.


回答1:


Uh, as I'd written the question out, it became obvious:

$something = array();

$this->getUser()->setAttribute('something', $something);

Resolved.



来源:https://stackoverflow.com/questions/2656570/symfony-1-4-storing-an-array-in-session-with-setattribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!