After thinking a lot about this, I came up with an explanation of this
strange behavior. The problem is that the login is called from the
popup.html page, while this ajax request is called within the
background.html page. Is there a way to maintain the same session
within two different pages accessing the server? That is, can I base
session on the user instead that on the pages? I know it sounds
strange but it's the only explanation I can get.