Getting IP to UserIdentity

To make the Yii login script (from the blog tutorial) more secure, I want to have it update a few fields in a db table called login (last ip logged in from, logincount, logintime, etc.). I’m trying to do it from the authenticate() function in UserIdentity.php, but what’s the best way to pass the current IP to UserIdentity? I can’t call getenv(“REMOTE_ADDR”) from there, but I can’t figure out how to pass it in (or if this is a good place to do it).

You can use CHttpRequest::getUserHostAddress() to retrieve the ip address.


Check this?

Ah, thanks to the both of you, this should help me work something out.

I think I solved the problem with this, in my LoginForm model.It’s not working consistently though.

$identity=new UserIdentity($this->username,$this->password);

			$identity->setState('js', $this->js_enabled);


Aright, so getting the IP was no problem; but now I’m faced with a similar problem. My login form has a hidden field that will be set to ‘1’ if javascript is enabled. What is the best way to make this something I can access from, say, Yii::app()->user->id? From what I understand, I can only user setstate() in UserIdentity, but then I have to decipher a way to get the $js variable from the LoginForm model to UserIdentity. Any suggestions?