Yii::app()->user->setState in yii?

▼魔方 西西 提交于 2019-12-11 02:23:13

问题


I want to know about this in yii:

Yii::app()->user->setState('key','value');

If I have a array of size 10 and I set this array in state like:

 Yii::app()->user->setState('data',$dataArray) 

I have another array of size 15000 and I set this array in state like:

Yii::app()->user->setState('data',$dataArray)

Is this Ok?

Or It will effect the speed of my Yii project i.e. larger the setState data size ,slower will be the speed of yii project?

Is it is secure way for confidential data like Password to set in Yii::app()->user->setState('password',$password)?


回答1:


Don't store the password in the setState due to security issue variables but if you need than use some encryption .

You can see here that the setState function is using the the session http://www.yiiframework.com/doc/api/1.1/CWebUser#setState-detail

You can store as much data as you like within in sessions. All sessions are stored on the server.There is no limit to the size of the session, But there is a limit to the memory PHP can take: http://ca.php.net/manual/en/ini.core.php#ini.memory-limit

Another very informative link regarding large data in session is

Is it okay to save lots of information in $_SESSION?

Thanks




回答2:


Please do not save the user personal information like Passwords or Keys etc. in setState function as this is setting your data in session which is created after users Authentication. So please do not store large data in setState function, It slows down your application performance either your session is stored in DB or in Cookie.



来源:https://stackoverflow.com/questions/25698430/yiiapp-user-setstate-in-yii

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