On Jun 20, 9:22 am, Darko <darko.maksimo...@gmail.comwrote:
On Jun 20, 6:12 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
pbd22 wrote:
when the user clicks on "signout" from any given page,
an XMLHttp call queries a server script (VB.NET) which
1) signs out the user if he is authenticated and
2) expires the cookie (DateTime.Now.AddYears(-1) ) for "user id".
How do I "immediately" destroy the
cookie so the user is both unauthenticated AND his
user id is removed.
Use javascript to delete cookie immediately:
document.cookie="NAME=;expires="+(new Date(99999).toGMTString())
You need to understand what "cookie" is to resolve this. A cookie is
simply a line of text in the http-response. If you get that text in an
ajax response (a response to the ajax request) than that won't affect
the cookies on the client's system. To my knowledge, only if you
navigate to a page that contains cookie definitions will affect the
client's cookies, not the ones sent in the ajax response. So, the
trouble is you would either need to parse the ajax response, or think
of something else. Like scripts.contact said, the easiest way to do
this is to ignore the response from the server in that case, and set
the cookie manually in the same javascript chunk of code.
Hi.
Thanks for your replies.
Client Side Cookies seem to be the answer but I can't seem to
get rid of the "loged-in" cookie. The current result is two
cookies with the same key: user id = BillG and user id = guest
I am using the below functions on sign-out:
function del_cookie(name) {
document.cookie = name +'=; expires=Thu, 01-Jan-70 00:00:01
GMT;';
}
function write_cookie (name, value, path)
{
// Build the expiration date string:
var expiration_date = new Date ();
expiration_date.setYear (expiration_date.getYear () + 1);
expiration_date = expiration_date.toGMTString ();
// Build the set-cookie string:
var cookie_string = escape (name) + "=" + escape (value) + ";
expires=" + expiration_date;
if (path != null)
cookie_string += "; path=" + path;
// Create/update the cookie:
document.cookie = cookie_string;
}
called as such:
del_cookie("user id");
write_cookie("user id", "guest", "/");
THIS DOESNT WORK :(