I have defined cookies using the following code snippet:
$cookies.userName = $scope.userName; ($scope.username represents a variable)
$scope.userName = $cookies.userName;
When rendering it in HTML, I use the following code:
{{userName}}
The cookies value is displaying correctly. The problem arises when a user logs in with username - aaa. The cookie then displays aaa.
Upon logout of user aaa and login of user bbb, the cookie value still shows as aaa
. However, upon refreshing the page, the cookie value changes to bbb
. This discrepancy only occurs after refreshing, not during normal logins that show the previous cookie value.
Could someone please recommend a solution for this issue?