Link to home
Start Free TrialLog in
Avatar of Mani Pazhana
Mani PazhanaFlag for United States of America

asked on

Request.Cookie

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



Avatar of Edgard Yamashita
Edgard Yamashita
Flag of Brazil image

you want to remove/clear the cookies ?

use Response instead of Request..

eg:

Response.Cookies.Clear()
Avatar of Mani Pazhana

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Edgard Yamashita
Edgard Yamashita
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Response.Cookies.Clear() did not clear Request.Cookies.Count, still the value exists.