login: function(user, success, error) {
var s = new session(user);
s.$login({}, function (u, putResponseHeaders) {
if ($cookies.user) {
console.log('cookie set' + $cookies.user);
user = JSON.parse($cookies.user);
}
else
console.log('no cookie set after login');
console.log(u);
$rootScope.user = user;
console.log($rootScope.user.role);
success(user);
}, function () {
error();
});
},
Upon clicking the login button, the server assigns an authentication cookie. The aforementioned function is responsible for handling this cookie and calling the success(user) function based on its presence. An issue arises where upon the first click of the login button, 'no cookie set after login' is displayed and the cookie is not detected. However, on the second click, authorization takes place successfully. While Google Chrome recognizes the cookie being set during the initial login attempt, the AngularJS code fails to acknowledge its existence. This inconsistency raises the question of why the AngularJS code is unable to detect the cookie when Chrome can.