Solved

Request.Cookie

Posted on 2008-10-08
4
335 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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