public static function restoreFromCookie(IModel $aUserModel) { // load model if (!$aUserModel->load($_COOKIE[self::COOKIE_KEY_USERNAME], 'username')) { self::clearCookie(); return null; } // login $aUserModel->setData('lastLoginTime', $_COOKIE[self::COOKIE_KEY_LOGINTIME]); // verify signture if (self::makeCookieSignture($aUserModel) != $_COOKIE[self::COOKIE_KEY_SIGNTURE]) { self::clearCookie(); return null; } return new Id($aUserModel); }