3

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

unknownbits
  • 2,855
  • 10
  • 41
  • 81

2 Answers2

3

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

Community
  • 1
  • 1
Arslan Butt
  • 775
  • 1
  • 8
  • 20
  • i used setState. when user login i set timezone value in setState. but i don't know what is problem. When it load fastly then works perfect. but when it take too much time to load then i don't get any value in setState. any help please. – Dhara Nov 28 '15 at 06:02
  • @Jazz why you are using setStateto save timezone value? Can you explain please or can I see your code? – Arslan Butt Nov 29 '15 at 16:47
  • i want timezone in my whole project so i am setting setState for getting timezone value. – Dhara Nov 30 '15 at 06:29
0

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.

Sam
  • 376
  • 3
  • 10