|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Trouble removing cookiesI am having trouble removing cookies that I created with my site. Here is
the code I am using to try and remove them: If Not Request.Cookies("username") Is Nothing Then Response.Cookies.Remove("username") If Not Request.Cookies("password") Is Nothing Then Response.Cookies.Remove("password") Is there something I am missing here? Even after I do a Session.Abandon() the cookies still seem to be there. Is there another step that is necessary? Thanks. Nathan,
Instead of removing the cookies (I believe that just removes them from the server memory and not the client) you should overwrite them on the client. If Not Request.Cookies("username") Is Nothing Then Response.Cookies("username") = "" End If Oh, and even an empty cookie may not be equal to "Nothing" because it is a string you may need to test for "" instead. -- Show quoteHide quoteSincerely, S. Justin Gengo, MCP Web Developer / Programmer www.aboutfortunate.com "Out of chaos comes order." Nietzsche "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message news:%23wp9CqPOGHA.3100@tk2msftngp13.phx.gbl... >I am having trouble removing cookies that I created with my site. Here is >the code I am using to try and remove them: > > > If Not Request.Cookies("username") Is Nothing Then > Response.Cookies.Remove("username") > If Not Request.Cookies("password") Is Nothing Then > Response.Cookies.Remove("password") > > > Is there something I am missing here? Even after I do a Session.Abandon() > the cookies still seem to be there. Is there another step that is > necessary? Thanks. > -- > Nathan Sokalski > njsokal***@hotmail.com > http://www.nathansokalski.com/ > I figured out how to remove them, which is to set the Expires property to
somewhere in the past and the use the Response.Cookies.Add() method. However, what is the point in removing the cookies from the server memory if they get resent with every Request anyway? Show quoteHide quote "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in message news:OIlG9PVOGHA.3944@tk2msftngp13.phx.gbl... > Nathan, > > Instead of removing the cookies (I believe that just removes them from the > server memory and not the client) you should overwrite them on the client. > > If Not Request.Cookies("username") Is Nothing Then > Response.Cookies("username") = "" > End If > > Oh, and even an empty cookie may not be equal to "Nothing" because it is a > string you may need to test for "" instead. > > -- > Sincerely, > > S. Justin Gengo, MCP > Web Developer / Programmer > > www.aboutfortunate.com > > "Out of chaos comes order." > Nietzsche > "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message > news:%23wp9CqPOGHA.3100@tk2msftngp13.phx.gbl... >>I am having trouble removing cookies that I created with my site. Here is >>the code I am using to try and remove them: >> >> >> If Not Request.Cookies("username") Is Nothing Then >> Response.Cookies.Remove("username") >> If Not Request.Cookies("password") Is Nothing Then >> Response.Cookies.Remove("password") >> >> >> Is there something I am missing here? Even after I do a Session.Abandon() >> the cookies still seem to be there. Is there another step that is >> necessary? Thanks. >> -- >> Nathan Sokalski >> njsokal***@hotmail.com >> http://www.nathansokalski.com/ >> > > Nathan,
I'm not certain about that myself... It really may just be the object they chose to hook up cookies with. It looks like the object is ultimately inheriting from something similar to arraylist (if it isn't arraylist itself I didn't bother to check). It may not be that they intended Remove to even be used. It may just have come along for the ride via inheritance. -- Show quoteHide quoteSincerely, S. Justin Gengo, MCP Web Developer / Programmer www.aboutfortunate.com "Out of chaos comes order." Nietzsche "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message news:O1oSTFbOGHA.2628@TK2MSFTNGP15.phx.gbl... >I figured out how to remove them, which is to set the Expires property to >somewhere in the past and the use the Response.Cookies.Add() method. >However, what is the point in removing the cookies from the server memory >if they get resent with every Request anyway? > -- > Nathan Sokalski > njsokal***@hotmail.com > http://www.nathansokalski.com/ > > "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote > in message news:OIlG9PVOGHA.3944@tk2msftngp13.phx.gbl... >> Nathan, >> >> Instead of removing the cookies (I believe that just removes them from >> the server memory and not the client) you should overwrite them on the >> client. >> >> If Not Request.Cookies("username") Is Nothing Then >> Response.Cookies("username") = "" >> End If >> >> Oh, and even an empty cookie may not be equal to "Nothing" because it is >> a string you may need to test for "" instead. >> >> -- >> Sincerely, >> >> S. Justin Gengo, MCP >> Web Developer / Programmer >> >> www.aboutfortunate.com >> >> "Out of chaos comes order." >> Nietzsche >> "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message >> news:%23wp9CqPOGHA.3100@tk2msftngp13.phx.gbl... >>>I am having trouble removing cookies that I created with my site. Here is >>>the code I am using to try and remove them: >>> >>> >>> If Not Request.Cookies("username") Is Nothing Then >>> Response.Cookies.Remove("username") >>> If Not Request.Cookies("password") Is Nothing Then >>> Response.Cookies.Remove("password") >>> >>> >>> Is there something I am missing here? Even after I do a >>> Session.Abandon() the cookies still seem to be there. Is there another >>> step that is necessary? Thanks. >>> -- >>> Nathan Sokalski >>> njsokal***@hotmail.com >>> http://www.nathansokalski.com/ >>> >> >> > >
ASP.NET 2.0 Easier than ASP? Gimmie a Break!
GridView and XmlDataSource TabStrip - create tabs dynamicly on client-side Trouble with DataList Control Trouble with the DataList Control Compare Validator for Date AND Time hyperlink in a Calendar Control ASP.Net 2.0 Table not expanding 100% GridView DataFormatString only works on Integers Wizard + control validation |
|||||||||||||||||||||||