code: function(options) {
        options = options || {};
        $.ajax({
          type: "POST", url: this.urlPrefix + "/_session", dataType: "json",
          data: {name: options.name, password: options.password},
          beforeSend: function(xhr) {
              xhr.setRequestHeader('Accept', 'application/json');
          },
          complete: function(req) {
            var resp = $.parseJSON(req.responseText);
            if (req.status == 200) {
              if (options.success) options.success(resp);
            } else if (options.error) {
              options.error(req.status, resp.error, resp.reason);
            } else {
              throw 'An error occurred logging in: ' + resp.reason;
            }
          }
        });
      }
docs: Authenticate against CouchDB, the <code>options</code> parameter is
  expected to have <code>name</code> and <code>password</code> fields.
  @param {ajaxSettings} options
  <a href="http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings">
  jQuery ajax settings</a>