My user authorization works fine without authKey
. I don't get how should I use it. But it's somehow more secure to use it as it stands in documentation.
I've implemented this methods in User ActiveRecord class.
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
public function validateAuthKey($authKey)
{
return $this->authKey === $authKey;
}
I even save it to user table on user creation. But I know that validateAuthKey
is never used. I'm using sessions and only PHPSESSID sent to user. Do I have to set authKey
cookie manually? What are the advantages of this? Why can't I authorize user just by PHPSESSID. It's already stored in session table. Session configuration:
'session' => [
'class' => 'yii\web\DbSession',
'sessionTable' => 'session',
],