How to get users last login time?

I have been following the cookbook

How to add more information to Yii::app()->user

http://www.yiiframew…doc/cookbook/6/

and I want to know what is the best method of extracting/recording a users last/previous login time?

I would pressume you could request this data from the session cookie, if so, how do you do this?

Basically I was following the

I think the most straight-forward way is to add a 'last_login' column into your user table, which stores the last login time, then you can follow the cookbook to assign that value to a user_identity when a user login.

Sorry will i was really vague with my question there.

I know how to add last login to my database in the user table and also assign a value to last_login in user_identity.

I want to know where/what is the best way to get this actual value for last_login, where last_login is the date/time the user logged into system not including this instance.

I know you could have two fields; one being login_date and the other being last_login (which is the previous login date). But I thought there might be a better way of doing than this

So by using my above method in the user_identity each time a user successfully logs into system the following would occur;

$this->last_login = $this->login_date

$this->login_date = new CDbExp​ression ('NOW());

Quote

So by using my above method in the user_identity each time a user successfully logs into system the following would occur;

$this->last_login = $this->login_date

$this->login_date = new CDbExp​ression ('NOW());

Why don't you use the same field? Get last_login, store in session for future session access and store NOW() to last_login.

Don't see any point here for using two different fields.

Sorry if i'm missing something here

Of course, dont know what I was thinking.

Thanks will