Solved

Request.Cookie

Posted on 2008-10-08
4
330 Views
Last Modified: 2013-12-17
Heelo Experts,

I am having issues in removing Request.Cookie on my ASP.Net page.

-------------------------------------------------------------
I do see the cookies in Request collection. But I could not clean them from my page.

----------------------------------------------------------

?Request.Cookies.Count
3

--------------------------------------------------
?Request.Cookies.Item(0)
{System.Web.HttpCookie}
    Domain: Nothing
    Expires: #12:00:00 AM#
    HasKeys: False
    Item: <cannot view indexed property>
    Name: "state%2Epa%2Eus"
    Path: "/"
    Secure: False
    Value: "564F8D424FAADCACC89595B5798F3606DE081B153C222D544EFBFBC74055BC5A1CE8744AA8A439B50162F9DC9987DD4B23D63B7786684FDFA13C35651FF643DC2B4C6813FCDA8307859E043A040F6AF01D2BC11B6FFB7BF487524040B57289CDE7DECCF1AF9E7EF6EE6B1BBF2FC941E162191367445D952996666A7F42971B95"
    Values: {System.Web.HttpValueCollection}


?Request.Cookies.Item(1)
{System.Web.HttpCookie}
    Domain: Nothing
    Expires: #12:00:00 AM#
    HasKeys: False
    Item: <cannot view indexed property>
    Name: "ASP.NET_SessionId"
    Path: "/"
    Secure: False
    Value: "5mb4k3ua1ezir2afenbxim45"
    Values: {System.Web.HttpValueCollection}


?Request.Cookies.Item(2)
{System.Web.HttpCookie}
    Domain: Nothing
    Expires: #12:00:00 AM#
    HasKeys: False
    Item: <cannot view indexed property>
    Name: ".ASPXAUTH"
    Path: "/"
    Secure: False
    Value: "6984F94F9B76C2170D27C711C30D0990ED4CA4893B2ACE978CAED6F4D758C3D87775572A05EAF0A3BF1CA1F9FF6796BF1CC99F39842860E20CE8B6F6A72391DDB8C05991BE473FDEB015C724B018563CC404EE4C4C1542C3"
    Values: {System.Web.HttpValueCollection}
--------------------------------------------------------------------

?Response.Cookies.Count
0

------------------------------------------------------------------

if you see above results, there is no Response.Cookie but there is some Request.Cookies.

-----------------------------------------------------------

I tried the following syntax: no luck so far.

 ' Work with cookies
                Dim testCookie As New HttpCookie("state%2Epa%2Eus")
                testCookie.Expires = DateTime.Now.AddYears(-30)

                Dim MyCookie As System.Web.HttpCookie = Request.Cookies("state%2Epa%2Eus")
                MyCookie.Expires = DateTime.Now.AddYears(-30)


                Dim objCookieColl As HttpCookieCollection
                objCookieColl = Request.Cookies
                objCookieColl.Remove("state%2Epa%2Eus")

                Dim strUS As String
                strUS = "state%2Epa%2Eus"
                Request.Cookies(strUS).Expires = DateTime.Now.AddYears(-10)
                Request.Cookies.Remove(strUS)
                Request.Cookies.Clear()
                Request.Cookies.Item(0).Expires = DateTime.Now.AddDays(-10)
---------------------------------------------

Can someone help me out with this issue? Thanks



0
Comment
Question by:mani_sai
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:eguilherme
ID: 22668998
you want to remove/clear the cookies ?

use Response instead of Request..

eg:

Response.Cookies.Clear()
0
 
LVL 8

Author Comment

by:mani_sai
ID: 22669140
There is nothing in Response.Cookies.Count.

I see cookies in Request.Cookies.Count. I want to remove the cookies from Request.Cookies.

Also I tried Response.Cookies, no luck.

Any idea?
0
 
LVL 10

Accepted Solution

by:
eguilherme earned 500 total points
ID: 22669221
Have you tried Response.Cookies.Clear() and then checking Request.Cookies.Count ?
0
 
LVL 8

Author Comment

by:mani_sai
ID: 22669361
Response.Cookies.Clear() did not clear Request.Cookies.Count, still the value exists.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now