473,511 Members | 14,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot delete cookies in ASP.NET code

3 New Member
Have spent hours reading all the posts regarding this problem and tried every example and no luck, cookies just won't go away. Worse is that there are 2 cookies with the same name and 2 different values.

Here is the code I use that just refuses to remove the cookies

Expand|Select|Wrap|Line Numbers
  1. Dim aCookieCustomerID As HttpCookie = Request.Cookies("CustomerID")
  2. If (Not aCookieCustomerID Is Nothing) Then
  3.       Request.Cookies.Remove("CustomerID")
  4.             aCookieCustomerID.Expires = DateTime.Now.AddYears(-30)
  5.       Response.Cookies.Add(aCookieCustomerID)
  6. End If
Oct 2 '12 #1
4 2291
RE6479
3 New Member
Decided to look at the actual cookie contents:

Expand|Select|Wrap|Line Numbers
  1. __utmz=132673228.1349116135.3.52.utmccn=(referral)|utmcct=/index.aspx|utmcmd=referral; CartID=625509; CustomerID=80247; __utma=132673228.339030113.1349109586.1349228425.1349271381.15; __utmb=132673228; __utmc=132673228; CustomerID=10790
Note there are 2 CustomerID entries. The site always grabs the 1st one and when I try to change it, the 2nd one changes but I can never get it back.

I see that I could write my own cookie parser and grab the correct one, which is what I'm about to do. The question is why are there 2 and why won't they clear? Does it perhaps have anything to do with the google junk between them?

Thanks
Oct 3 '12 #2
madankarmukta
308 Contributor
Set the attributes - the path and the domain of the cookie.

Thank you.
Oct 3 '12 #3
RE6479
3 New Member
Got it to work, but I had to do it twice, one with domain with the "WWW" and one without.

Oddly before adding the domain, when I tried to display cookie.domain it returned blank and my understanding was that if the domain was not specified ALL site pages (which are all in the same folder) would all be the default domain.

So I thank you for pointig me in the right direction.
Oct 4 '12 #4
madankarmukta
308 Contributor
Pleased to help.

Kindly buzz back for any technical help w.r.t ASP.net and JavaScript cookies.

Happy coding!
Oct 4 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3748
by: David | last post by:
I have a problem that I cannot delete components that are placed on a R\abbed page in Visual Basic.Net 2003. The form uses a Tab Control with several pages. I have a Panel on the page and then...
2
3067
by: Dan | last post by:
I persist the login info using cookies so that a user doesn't have to login every time they come to our website, unless they previously logged out. Everything works OK on W98 SE, and Windows XP Pro...
3
11986
by: Bob Darlington | last post by:
Using Access 2002. I have imported one form and two modules from another database, in order to compare code. Having finished the comparison, I cannot delete them. When I press 'Delete', I get a...
2
5184
by: phoenix | last post by:
Hello, I tried the following to delete the cookies Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Cookies ), true); but always get the message that "index.dat" is...
2
1367
by: Natan | last post by:
I'm getting this exception when trying to delete a file: System.UnauthorizedAccessException: Access to the path "d:\root\sigma\anexos\" is denied. the thing is that i can save files in this...
3
2615
by: kendera | last post by:
Is it possible to programmatically delete cookies? Can anyone help me with this...
8
16160
Inbaraj
by: Inbaraj | last post by:
Hi... I want to Set Get Delete Cookies using javascript i saw in net but i cant understand... Plz help me with sample example..... with reg inba
5
11507
by: gibble | last post by:
Hi, I am going crazy. We get a hundred or so of these errors each day and while the fix would seem obvious, the error does not include a line number! -------------------- Process...
4
1261
smiley22
by: smiley22 | last post by:
hi guys, i had a problem with my codes, the problem is I cannot delete the inputs in the first 3 fields if I want to delete it. Here is the code: <head> <script language="JavaScript"> ...
2
14979
by: SCPOS | last post by:
Cannot delete X: It is being used by another person or program. Close any programs that might be using the file and try again. Of course I have tried closing any programs I know of that may be...
0
7245
marktang
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,...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
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,...
0
3227
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...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.