Skip to content

Instantly share code, notes, and snippets.

@DrMabuse23
Created August 28, 2014 16:44
Show Gist options
  • Save DrMabuse23/11b8ee985da2f33a1489 to your computer and use it in GitHub Desktop.
Save DrMabuse23/11b8ee985da2f33a1489 to your computer and use it in GitHub Desktop.
ip2long problem
/**
* Logs in a user using the provided username and password.
*
* @return boolean whether the user is logged in successfully
*/
public function login()
{
if ($this->validate()) {
$this->user->setAttribute('logged_in_from', ip2long(\Yii::$app->getRequest()->getUserIP()));
$this->user->setAttribute('logged_in_at', time());
$this->user->save(false);
return \Yii::$app->getUser()->login($this->user, $this->rememberMe ? $this->module->rememberFor : 0);
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment