?
Solved

Request.Cookie

Posted on 2008-10-08
4
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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