This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$cookies missing after Ajax request #10861
Closed
Description
It's hard to make a plunkr example, but it's easy to reproduce.
As I have a SPA I do authentication serverside through $http (webAPI). I create a $http method which calls a login functions on my backend server, this will set a cookie to authenticate.
After $http is complete I check my cookies:
public get isAuthenticated(): boolean
{
var cookie1: string = $cookie['.ASPXAUTH'];
var cookie2: string = $cookie['.ASPXAUTH_USERID'];
console.log(cookie1, cookie2);
console.log(document.cookie);
if (cookie1 && cookie2)
{
return true;
}
return false;
}
Odd part is that the variables cookie1
and cookie2
are empty, but document.cookie
contains the newly set cookies.
After a page refresh all is fine, it seems that $cookie doesn't recognize cookies after they have been set by an ajax call.