You don't actually remove the cookie. You have to force the cookie to expire so that when it is read on the client, it will be passed its expiration date and will be removed. Then, when you go back to the server on your next request, the cookie will no
longer be available.
By deleting the cookie on the server, you only force your next request to send back the cookie that's still there, thus having the cookie come back to the server.
Set the Expires property on your cookie to either DateTime.Now or something like DateTime.Now.AddSeconds(-60) so that it will be clearly passed the expiration time when the cookie returns to the client.
Christopher Reed, MCT, MCSD, MCPD, Microsoft Specialist, MTA, MCTS
"The oxen are slow, but the earth is patient."
As Careed said, you didn't actually delete the cookie. As for delete a Cookie, we could set the cookie's expiration date to a time in the past. Like this:
If (Not Request.Cookies("UserSettings") Is Nothing) Then
Dim myCookie As HttpCookie
myCookie = New HttpCookie("UserSettings")
myCookie.Expires = DateTime.Now.AddDays(-1D)
Response.Cookies.Add(myCookie)
End If
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
75 Points
318 Posts
removing cookies
Feb 03, 2015 10:57 AM|volar5|LINK
Hi all:
I have
In transferir I remove the cookie. If I ask for it after the removal, I get an error. So it is ok, it is removed
But in comprobar_cuenta, where I authenticate, if I ask for the cookie before the test, the cookie is there. What happens?
Thanks in advanced
Star
13130 Points
4049 Posts
Re: removing cookies
Feb 03, 2015 01:05 PM|Careed|LINK
You don't actually remove the cookie. You have to force the cookie to expire so that when it is read on the client, it will be passed its expiration date and will be removed. Then, when you go back to the server on your next request, the cookie will no longer be available.
By deleting the cookie on the server, you only force your next request to send back the cookie that's still there, thus having the cookie come back to the server.
Set the Expires property on your cookie to either DateTime.Now or something like DateTime.Now.AddSeconds(-60) so that it will be clearly passed the expiration time when the cookie returns to the client.
"The oxen are slow, but the earth is patient."
All-Star
45489 Points
7008 Posts
Microsoft
Re: removing cookies
Feb 03, 2015 09:17 PM|Zhi Lv - MSFT|LINK
Hi volar5,
As Careed said, you didn't actually delete the cookie. As for delete a Cookie, we could set the cookie's expiration date to a time in the past. Like this:
For more details, please refer to this articles.
https://msdn.microsoft.com/en-us/library/ms178195(v=vs.100).aspx
Best Regards,
Dillion
Member
75 Points
318 Posts
Re: removing cookies
Feb 04, 2015 03:41 AM|volar5|LINK
Hi:
Thanks for the reply. At last I found the solution.
I wonder why have I to put the request.cookies.remove("cuenta")
Thanks again