Cookies management removed, the most necessary code left when trying to narrow down a problem where user was not being authenticated during login by service.