473,804 Members | 3,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting Cookies

Hi all,
Environment : ASP.NET
I am using cookies to store some data. this is done in a class which is
called by a web page CookieCreate.as px. Here is a little bit of code of how i
create the cookie in the class
Dim context As HttpContext = HttpContext.Cur rent

If Not context.Request .Cookies("CartI D") Is Nothing Then

Return context.Request .Cookies("CartI D").Value

Else

' Generate a new random GUID using System.Guid Class
Dim tempCartId As Guid = Guid.NewGuid()
context.Respons e.Cookies("Cart ID").Value =
tempCartId.ToSt ring()

End If
Now when i want to delete this cookie in another page which is
CookieDelete.as px i am not able to do it, the code that i am using to delete
it is

Session.Clear()
HttpContext.Cur rent.Request.Co okies.Clear()
HttpContext.Cur rent.Items.Clea r()

i was thinking one of them shold delete all the cookies that my other
webpage might have opened but it is not, so the questions is how can i delete
a cookie from page B when page A or any other page has create it?

thanks
sameer
Apr 12 '06 #1
1 2466
Dim i As Integer
Dim cookieName As String
Dim limit As Integer = Request.Cookies .Count - 1
For i = 0 To limit
aCookie = Request.Cookies (i)
aCookie.Expires = DateTime.Now.Ad dDays(-1)
Response.Cookie s.Add(aCookie)
Next

http://msdn.microsoft.com/library/de...cookies101.asp
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"sameer" wrote:
Hi all,
Environment : ASP.NET
I am using cookies to store some data. this is done in a class which is
called by a web page CookieCreate.as px. Here is a little bit of code of how i
create the cookie in the class
Dim context As HttpContext = HttpContext.Cur rent

If Not context.Request .Cookies("CartI D") Is Nothing Then

Return context.Request .Cookies("CartI D").Value

Else

' Generate a new random GUID using System.Guid Class
Dim tempCartId As Guid = Guid.NewGuid()
context.Respons e.Cookies("Cart ID").Value =
tempCartId.ToSt ring()

End If
Now when i want to delete this cookie in another page which is
CookieDelete.as px i am not able to do it, the code that i am using to delete
it is

Session.Clear()
HttpContext.Cur rent.Request.Co okies.Clear()
HttpContext.Cur rent.Items.Clea r()

i was thinking one of them shold delete all the cookies that my other
webpage might have opened but it is not, so the questions is how can i delete
a cookie from page B when page A or any other page has create it?

thanks
sameer

Apr 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
3287
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. For example, if my site is www.test.com and the cookie contains: label1 fob
1
5978
by: Michal A. Valasek | last post by:
Hello, I have problem deleting cookies and cookies values (using framework version 1.1 on W2003). When I try to remove entire cookie, by calling Response.Cookies.Remove("Test"), nothing happens, the cookie "Test" remains unchanged. When I try to remove one of cookie values, by calling
2
2651
by: James | last post by:
Help! I've made a cookie with a key called 'List' and subkey 'item3' and assigned it a value of "3" Response.Cookies("List")("item3")="3" How do I now delete the subkey "item3" without deleting any other subkeys that might be in 'List'???
4
5166
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, if I have this cookie header in a response: Set-Cookie: CookieName=; path=/;expires=01-Jan-1999 00:00:00 GMT the cookie is not deleted for the next request, what should be and actually done with Internet Explorer as client. is this a bug is there a solution / workaroung by manually deleting the cookie?
4
2006
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, i make more than one request and needs to handle cookies being added and removed between requests, just like a regular web browser like internet explorer. if I have this cookie header in a response: Set-Cookie: <CookieName>=; path=/;expires=01-Jan-1999 00:00:00 GMT the cookie is not deleted for the next request, and is being sent again with
0
9705
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, 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...
0
10323
jinu1996
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...
1
10310
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
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...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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 we have to send another system
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.