service = $service; $this->user = $this->restore('user'); } public function getUser () { return $this->user; } // Action Interface public function login ( $user ) { // query for ( login, pass ) $users = $this->service; // no match ( login, pass ) if ( empty($users[$user['login']]) ) throw new Exception('Wrong user !'); if ( $users[$user['login']]['password'] !== $user['password'] ) throw new Exception('Wrong password !'); $this->user = $users[$user['login']]; $this->store('user', $this->user); } public function logout () { $this->user = null; $this->store('user', null); $_SESSION = array(); } } ?>