Yii Framework Forum: Question about CWebUser::$allowAutoLogin - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Question about CWebUser::$allowAutoLogin Rate Topic: -----

#1 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 05 January 2010 - 10:01 AM

If I want to allow a user to stay (auto-) logged in for up to one year, do I really have to set the cookie lifetime of the session component to one year? That would mean any session remains valid for a year and that would result in a lot of trash. At this point I see no other solution? :mellow: Or did I missed something?
0

#2 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 08 January 2010 - 02:24 AM

Anyone? :mellow:
0

#3 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 08 January 2010 - 03:09 AM

At login model there is the code
public function authenticate($attribute,$params)
	{....$duration=$this->rememberMe ? 3600*24*30 : 0;//// 30 days,set it for 1 year
       Yii::app()->user->login($identity,$duration);

I also extend the function authenticateByCookie().
I thing at cookie will be only the information of Yii::app()->user and not all the session.Is not it?
Posted Image
0

#4 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 08 January 2010 - 03:22 AM

View Postdimis283, on 08 January 2010 - 03:09 AM, said:

At login model there is the code
public function authenticate($attribute,$params)
	{....$duration=$this->rememberMe ? 3600*24*30 : 0;//// 30 days,set it for 1 year
       Yii::app()->user->login($identity,$duration);

I also extend the function authenticateByCookie().
I thing at cookie will be only the information of Yii::app()->user and not all the session.Is not it?


Well as far as I noticed the "autologin"-cookie stores the id of the current session. If the stored session id is not valid anymore (expired), autologin fails. Or is this not the case? I can't test at the moment.
0

#5 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 08 January 2010 - 03:47 AM

Me personally I extended the function authenticateByCookie() and I made there the validation.
I took that from here
Posted Image
0

#6 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 08 January 2010 - 04:14 AM

Alright I did obviously made a mistake when first testing this feature. Just tested again and it works without problems.

View Postdimis283, on 08 January 2010 - 03:47 AM, said:

Me personally I extended the function authenticateByCookie() and I made there the validation.
I took that from here


Thanks for the hint, I will extend CUserIdentity and CWebUser.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users