I'm having trouble with cookies and getting some weird behavior. For now the cookie are set on sign in like so:
document.cookie = "cookie1=" + cookie1 + "; expires=0; path=/";
document.cookie = "basicAuth=" + basicAuth + "; expires=0; path=/";
document.cookie = "cookie2=" + cookie2 + "; expires=0; path=/"
That works fine. I have a sign out button in the header and on click it does the following:
document.cookie = "cookie1=";
document.cookie = "basicAuth=";
document.cookie = "cookie2=";
In the header script I have a simple check to see if cookie1 is empty and to hide the header nav bar and redirect to sign in if it is:
if (getCookie("cookie1") == "") {
$(".navbar").css({"display":"none"});
window.location.href = "/signin";
}
Right now I am able to log out effectively the first time, but logging back in and logging out again seems not to work properly. I still see the navbar and the redirect seems to only work selectively. Is there a better way to set or delete cookies?