Reputation: 123
New to AngularJS web development. Currently, I have an application where I have to use the global authentication form. The SPA has multiple partial pages/views. To navigate from tab to tab, I am using ngCookies to store the customer login information.
If the user refreshes the page, I read the cookies and bring the related information for a given customer.
It is working fine but the problem arises when the user closes the application without clicking the logout button and the cookies remain in the browser.
So, the next time another customer logs onto the site, it reads the old cookies and bring the old customer information instead of currently logged-on user.
function writeLoginCustIDCookie(loginCustID) {
$cookies.put("LoginCustID", loginCustID, { path: '/' });
}
function getLoginCustIDCookie() {
return $cookies.get("LoginCustID");
}
Please help me out how to solve this issue.
Upvotes: 0
Views: 1371
Reputation: 5041
You will have to configure a flow. What I do is this:
withCredentials: true
to your http requests, so that cookies are sent.This is what I generally do. Nothing crazy I think.
Upvotes: 1