1

I am writing a couchapp, which uses the couch.jquery.js library.

When I login to the site with ie8, i get a successful login (it returns ok, and a login id), but when I query the session, I get a userCtx.name of null (just like if the login didn't happen).

It would seem that explorer will not keep the cookie from the login. Does anyone have any info on this? I have tried J Chris's couchLogin.js library and written my own login scripts with the same problem.

The session code is:

$.couch.session({
    success: function(data) {
        console.log(JSON.stringify(data));
    }
});

Response from IE:

{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["oauth","cookie","default"]}}

Response from Firefox / Chrome:

{"ok":true,"userCtx":{"name":"user1","roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["oauth","cookie","default"],"authenticated":"cookie"}}
ddouglascarr
  • 1,334
  • 3
  • 14
  • 23
  • what version of jquery are you using? have you checked the browser console for any errors? – SDC Mar 21 '13 at 11:54
  • Thanks for your response. no errors on console. I've had it log the responses, and the code executes fine, it just thinks the user is logged out. I'm using JQuery 1.9.1 (with jquery-migrate-1.1.1). Also tried with jQuery-1.8.3. (I've added the call and response to the question) – ddouglascarr Mar 21 '13 at 21:46

1 Answers1

0

I have solved this by editing jquery.couch.js, and adding cache:false to ajax call in the session function.

session: function(options) {
  options = options || {};
  $.ajax({
    cache: false,  //disable caching for IE
    type: "GET", url: this.urlPrefix + "/_session",
    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 getting session info: " + resp.reason;
      }
    }
  });
}
ddouglascarr
  • 1,334
  • 3
  • 14
  • 23
  • Hey I'm having a similar problem: . Do you think the fix you've applied would also work? Where exactly is the source for `jquery.couch.js`? – blaineh Oct 16 '13 at 17:27
  • I just tried it, and it didn't have any effect. I'm still getting a null name. – blaineh Oct 16 '13 at 17:37
  • Also, I'm having this issue with Chrome, so I doubt it's a browser issue, especially since you didn't have any problems with Chrome. – blaineh Oct 16 '13 at 17:47