Hi.
I am having a hard time figuring this one out...
I have a sign in page. in my sign in logic, the successful
login uses forms authentication and assigns an HttpCookie
for the site-wide "user id" (ie. "Welcome BillG ! ").
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.A ddYears(-1) ) for "user id".
my problem is that when the request is returned to the
client, it seems to have no effect on the status of the cookie. It
still reads "user id = BillG" when i do javascript:docu ment.cookie.
Is it possible that my server code:
Response.Cookie s.Add(cookie)
got complicated with the AJAX call? How do I "immediatel y" destroy the
cookie so the user is both unauthenticated AND his
user id is removed.
I hope I have explained myself clearly. Thanks for your replies.
Peter 5 22574
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.A ddYears(-1) ) for "user id".
How do I "immediatel y" 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).toG MTString())
On Jun 20, 6:12 pm, "scripts.contac t" <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.A ddYears(-1) ) for "user id".
How do I "immediatel y" 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).toG MTString())
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.
On Jun 20, 9:22 am, Darko <darko.maksimo. ..@gmail.comwro te:
On Jun 20, 6:12 pm, "scripts.contac t" <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.A ddYears(-1) ) for "user id".
How do I "immediatel y" 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).toG MTString())
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_dat e.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("use r id");
write_cookie("u ser id", "guest", "/");
THIS DOESNT WORK :(
On Jun 20, 1:14 pm, pbd22 <dush...@gmail. comwrote:
On Jun 20, 9:22 am, Darko <darko.maksimo. ..@gmail.comwro te:
On Jun 20, 6:12 pm, "scripts.contac t" <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.A ddYears(-1) ) for "user id".
How do I "immediatel y" 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).toG MTString())
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_dat e.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("use r id");
write_cookie("u ser id", "guest", "/");
THIS DOESNT WORK :(
Hi. I found the Answer. It is cut and paste below:
FIXED!
It seems that the cookie string used in JavaScript to delete it must
match
EXACTLY the cookie string sent by ASP.NET to save it:
as ASP.NET sends:
login=myloginva lue; expires=gmtdate ; path=/
You have to write the following JavaScript to delete the cookie:
var expires = new Date();
expires.setUTCF ullYear(expires .getUTCFullYear () - 1);
document.cookie = 'login=; expires=' + expires.toUTCSt ring() + ';
path=/';
It works both on IE and Mozilla!
Henri
In comp.lang.javas cript message <11************ ********@x35g20 00prf.goog
legroups.com>, Wed, 20 Jun 2007 09:12:18, scripts.contact
<sc************ *@gmail.compost ed:
> Use javascript to delete cookie immediately: document.cooki e="NAME=;expire s="+(new Date(99999).toG MTString())
Why 99999 rather than 0 ? But
document.cookie ="NAME=;expires =Thu, 1 Jan 1970 00:01:39 UTC"
is shorter.
Probably, one does not need the "Thu, ", the " UTC", and maybe not even
the " hh:mm:ss".
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brian Burgess |
last post by:
Hi all,
Anyone know of any special issues with storing cookies with ASP? I'm
trying this with two browsers: One is IE 6.0 with cookies set to
'prompt'. This has been working properly as any new site I goto seems
to prompt me to store their cookie. The other is Pocket IE on Pocket
PC 2002, with the cookies set to 'enabled'.
My problem is that the cookies dont seem to be being written with my
ASP. I dont get the prompt to store...
|
by: serge calderara |
last post by:
Dear all,
I try to make some test on how to use basic cookie but get some trouble in
the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then
If Request.Browser.Cookies Then
If Not IsNothing(Request.Cookies("PS")) Then
|
by: yawnmoth |
last post by:
Say I wrote an ajax script to send out HTTP requests via ajax. Any
cookies that I have associated with that site will be sent along with
this HTTP request. Is there a way to prevent this from happening? I
tried the following to no avail:
http.setRequestHeader('Cookie','');
|
by: Mr. SweatyFinger |
last post by:
OK I don't understand ajax, but my page makes a quick ajax call to another
page and returns the results.
that works ok.
That other page is supposed to set a cookie.
That doesn't seem to work.
Is that because ajax doesn't send all the headers and cookies, or am i being
a big dumb jerk?
|
by: dougloj |
last post by:
Hi.
I have an ASP.NET application written in C#. In part of my
application, I want to use JavaScript OnClick event function to
update a textbox with a string generated asynchronously on the server.
I have pretty much figured out two ways to this. One way involves
AJAX. The other way involves using cookies.
I think AJAX is awesome, but what if the user's browser blocks ActiveX
controls? On the other hand what if the browser blocks...
| |
by: tomb |
last post by:
I am setting a cookie in my php code. In one portion of the page, a
user click will activate AJAX and the form will be posted to a php
script for a dynamic update. Will that php script have access to my
previous cookie?
TIA
Tom
|
by: John Grandy |
last post by:
Is anyone finding that cookies added to the Response.Cookies collection
within pages which contain an UpdatePanel do not exist in the
Request.Cookies collection when the page is posted back ?
These should be complete page postbacks not partial postbacks, because the
postback in question is not triggerred by a control inside the UpdatePanel
(nor is it a trigger control for an UpdatePanel), but, not knowing all the
details of how AJAX...
|
by: _Who |
last post by:
Given Request.Cookies and Response.Cookies in asp.net is there any reason to
ever use javascript or any other method to use cookies?
Thanks
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |