final public function write($sessId, $data = array())
    {

        //Writes user data to the db;
        $self = $this;

        //expires
        $expires = time() + $self->life;

        //Sets the cookie
        //$output->setCookie($self->cookie, $sessId."0".$data['token'], $expires);
        //$output->setCookie($sessId, $data['token'], $expires);
        $cookie = session_get_cookie_params();

        //Cookie parameters
        session_set_cookie_params($expires, $cookie['path'], $cookie['domain'], true);

        $self->id = session_id();
        $userdata = $this->input->serialize($self->registry);

        //last modified = now;
        //expires = now + life ;
        $handler = $this->handler;

        if (!$handler->write($userdata, $data, $self, $sessId, $expires)) {
            return false;
        }

        return true;
    }