【发布时间】:2012-02-02 13:32:25
【问题描述】:
我正在使用 CI,我有一个 UserModel,它根据登录信息选择用户并设置一个 userVO 并将这个 userVO 添加到这样的会话中:
$this->session->set_userdata('user', $userVO);
当我尝试访问此会话时,它会返回此错误:
Message: main() [function.main]: The script tried to execute a method
or access a property of an incomplete object. Please ensure that the
class definition "UserVO" of the object you are trying to operate on
was loaded _before_ unserialize() gets called or provide a __autoload()
function to load the class definition.
我找到了一个“解决方案”,我需要 CI 在会话类之前加载 UserVO 类并且它可以工作。
问题是我有很多 os VO 类,我会在会话中需要它们,自动加载它们是一件坏事,因为我不会同时需要它们。
有什么解决办法吗?
提前感谢您的帮助。
【问题讨论】:
-
I have lots os VO classes and I'll need them inside the session旁注:请记住,CI 的会话是 cookie,因此仅限于 4Kb 左右的空间。当然,除非你使用数据库。 -
@DamienPirsy 感谢您的提示,但这不是问题 =]
标签: php session object codeigniter-2