pass) != $password) { return false; } if (!self::isActive(self::$user->id)) { return false; } self::setSession(); return true; } static function logout() { Env::setCookie(session_name(), '', 0); Env::setCookie('login', '', 0); Env::setCookie('login_hash', '', 0); if (session_id()) { session_destroy(); } } static function process() { if (Env::getCookie(session_name())) { //есть сессия session_start(); } elseif (Env::getCookie('login') && Env::getCookie('login_hash')) { self::remember(); } } static function setSession() { Env::setCookie('login', self::$user->login, TIME_NOW + LOGIN_COOKIE_TTL); Env::setCookie('login_hash', self::getHash(), TIME_NOW + LOGIN_COOKIE_TTL); session_start(); $_SESSION['user'] = self::$user; } static function remember() { if (! self::$user = self::getByLogin(Env::getCookie('login'))) { self::logout(); } if (Env::getCookie('login_hash') == self::getHash()) { self::setSession(); } else { self::logout(); } } static function getHash() { return md5(self::$user->id.'hckrz'.self::$user->login.'mst'.self::$user->pass.'dai'); } static function getInfo() { return Env::Session('user', self::$user); } static function isGuest() { return ! (bool) Env::Session('user'); } static function getByLogin($login) { return Load::model('UserData')->getByLogin($login); } static function isActive($user_id) { return Load::model('UserActivate')->isActive($user_id); } } ?>