function write($sess_id, $data) { # Select the data belonging to session $sess_id from the session table $session = $this->find($sess_id); $session = $session instanceof ActiveRecordStore ? $session : $this; $session->id = $sess_id; $session->data = $data; $session->client_ip = $this->escape(Session::get_client_ip()); $session->http_user_agent = $this->escape($_SERVER['HTTP_USER_AGENT']); # Write the serialized session data ($data) to the session table return $session->save() ? true : false; }