Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Destroying Cookies?

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
We know we can set a cookie on a users computer by using:

Response.Cookies("name") = "John Doe"

and we can get the value like so:

Request.Cookies("name")


We also know we can use multple values in a cookie like this:

Response.Cookies("user")("id") = "1"
Response.Cookies("user")("name") = "John Doe"
Response.Cookies("user")("email") = "jdoe@abc.com"


Now the question comes:

How do you destroy a cookie on a users machine with multiple values? I've tried:

Response.Cookies = "0" And
Response.Cookies = ""


But neither works. Anyone know?

Thanks in advance!
-Ovatvvon :-Q
 
Hi,

You have to specify the variable and empty it
ex.
Response.Cookies("user")("id") = ""
Response.Cookies("user")("name") = ""
Response.Cookies("user")("email") = ""

hope this help.
 
will that delete the whole cookie, or only empty the specified fields (even if it's all of them)? -Ovatvvon :-Q
 
I did that, but it did not work. Any other suggestions? -Ovatvvon :-Q
 
Hello,

I just want to know what's the use of that user in Response.cookies("user")("id") 'coz when I set a cookie i usually used this syntax:
Response.Cookies("name")="paul"
Response.Cookies("emailadd")="xyz@a2zglobe.com"
to empty:
Response.Cookies("name")=""
Response.Cookies("emailadd")=""

Try this it works in mine.
 
Here's the best info I could find from devguru:

Response.Cookies(Name)[(Key)|.Attribute]=Value

Expires is write-only and is the date on which the cookie expires. Unless a date is specified, the cookie will expire when the session ends. If a date is specified, the cookie will be stored on the client's disk after the session ends.


.Expires is an attribute in the syntax above.

They don't list a .remove() function or anything, which means there isn't one, so I guess this is about the best we can do.
penny.gif
penny.gif
 
Renzy,
They way you are doing I believe creates mutple cookies...the way I listed keeps related inforamtion together in one cookie which is useful for what I want to do which is allow the person logging into my site to be "remembered" so they don't have to log in every time...to do this, I need to put some inforamtion about their account in a cookie on their machine and check for it when they come to the login page. However, if they want to stop the login "remember" function, I want to allow them to do that without having to empty all of their cookies.

Link9,
I tried setting the .Expires attribute to now(), however that didn't get rid of the cookie. This seams a bit odd to me.

thoughts? -Ovatvvon :-Q
 
Well, I'm guessing that the cookie isn't actually deleted, just becomes inaccessible to you, as the developer, after the .expires date passes.

And, judging from what devguru had to say about it, where if you don't explicitly set the .expires, and it expires when the session is over, then I'm guessing that they really don't ever truly get deleted... just inaccessible.

I know that before I started setting a limit on the size of my cookies folder, it used to grow to inordinate sizes, so I think that pretty much keeps with what we've discovered here.

Sounds on the surface like a real shortfall, but I guess it keeps with the security model of the browser and client computers...

It allows you to add and modify, but delete nothing from a users computer w/o them accepting some activeX control or something along those lines. As I'm thinking about it, it sort of makes sense to me.

Just conjecture, though. I found nothing to support that conclusion in writing or anything.
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top