public function login($password) { static::logout(); if (!password::match($password, $this->password)) { return false; } // create a new session id s::regenerateId(); $key = $this->generateKey(); $secret = $this->generateSecret($key); s::set('kirby_auth_secret', $secret); s::set('kirby_auth_username', $this->username()); cookie::set(s::$name . '_auth', $key, s::$cookie['lifetime'], s::$cookie['path'], s::$cookie['domain'], s::$cookie['secure'], s::$cookie['httponly']); return true; }
public static function logout() { s::regenerateId(); s::remove('auth.created'); s::remove('auth.updated'); s::remove('auth.key'); s::remove('auth.secret'); s::remove('auth.username'); s::remove('auth.ip'); s::remove('auth.ua'); cookie::remove('key'); }