public function create_session() { if (!$this->is_authorized()) { throw new Exception('User is not authorized. Could not create session.'); } $session = new AmySession($this->configuration); $session->create($this->userId); $this->save_user_to_session($session); $this->session = $session; return $session; }