Determine Last User Logged


How can I track, when user was logged in for the last time using Yii? When I used simply PHP, I redefined session storage to DB and was tracking session end, and put this time to the "lastLogged" field in the user table. How can I achieve this with Yii?

Probably the same way, Make a column in the users table that will store the last login time and update it each time a member logs in.

Is there any other solution? If not, then how to transfer newLogin dateTime to oldLogin time

here is my code


public function authenticate()







	else if(md5($this->password)!==$user->password)




	else if($user->active == 0)


	else if($user->locked == 0)






		$this->_role=$user->role->name;  // save role for use in app


		User::model()->updateByPk($user->id,array('newLogin'=> date("Y-m-d H:i:s"), 'ip'=> $_SERVER['REMOTE_ADDR'] ));

		User::model()->updateByPk($user->id,array('oldLogin'=> date("Y-m-d H:i:s")));


		$user_log= new UserLog();


		$user_log->time=date("Y-m-d H:i:s");






	return !$this->errorCode;