473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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.aspx. Here is a little bit of code of how i
create the cookie in the class
Dim context As HttpContext = HttpContext.Current

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

Return context.Request.Cookies("CartID").Value

Else

' Generate a new random GUID using System.Guid Class
Dim tempCartId As Guid = Guid.NewGuid()
context.Response.Cookies("CartID").Value =
tempCartId.ToString()

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

Session.Clear()
HttpContext.Current.Request.Cookies.Clear()
HttpContext.Current.Items.Clear()

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 2449
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.AddDays(-1)
Response.Cookies.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.aspx. Here is a little bit of code of how i
create the cookie in the class
Dim context As HttpContext = HttpContext.Current

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

Return context.Request.Cookies("CartID").Value

Else

' Generate a new random GUID using System.Guid Class
Dim tempCartId As Guid = Guid.NewGuid()
context.Response.Cookies("CartID").Value =
tempCartId.ToString()

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

Session.Clear()
HttpContext.Current.Request.Cookies.Clear()
HttpContext.Current.Items.Clear()

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
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. ...
1
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...
2
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...
4
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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
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,...

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.