I'm not entirely sure if this is down to the way we have our server setup or not, but in order to get cookie authentication to work I had to modify the CouchBase GetSession method, even after reading the documentation I'm still confused as to why I had to add this, but it seems to work great now...
(I added the line to include the Authorization header to the web request, it seems to require that and also the form data)
public Cookie GetSession()
var authCookie = cookiestore["authcookie"];
if (authCookie != null)
if (string.IsNullOrEmpty(username)) return null;
var request = new CouchRequest(baseUri + "_session");
request.GetRequest().Headers.Add("Authorization:Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password)));
var response = request.Post()
.Data("name=" + username + "&password=" + password)
var header = response.Headers.Get("Set-Cookie");
if (header != null)
var parts = header.Split(';').Split('=');
authCookie = new Cookie(parts, parts);
authCookie.Domain = response.Server;
cookiestore.Add("authcookie", authCookie, TimeSpan.FromMinutes(9));
Thanks for the contributions. It will be helpful if you can fork and send me pull request for these rather than just providing the comment.
Let me know if there is anything I can do to help.
Fixed issue #14. Authorization header not passed on session request.
Fixed in 7bf7c1.
Sorry about the delay. I can get to these much quicker if you can send me pull request in the future. Thanks for your contribution though.