Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Request.Cookie

Posted on 2008-10-08
4
Medium Priority
?
342 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

971 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