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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting rid of cookies

Status
Not open for further replies.

SPrelewicz

Programmer
Jul 16, 2001
124
US
I have a shopping cart type-ish of a thing. I want a user to be able to move around the site and add stuff that gets added to a cookie's value. When they go to the "cart", the CGI reads the cookie and slits/parses it up to fillin the "cart". No problem there.

Now, when a user hits submit, I redirect to a page, "thankyou", that has a SSI that runs a CGI that is supposed to destroy the cookie.

Here's that script:

#!/usr/local/bin/perl

#use CGI ':standard';
use CGI;

my $co=new CGI;

$cookie = $co->cookie
(
-name=>'data',
-value=>'',
-path=>'',
-expires=>'Wednesday, 8-Aug-02 23:59:59 GMT',

);

print $co->header(-cookie=>$cookie);


As you can see, I set the date to the past AND the value to null. But after I submit and this page is run, I go to add something else to the "cart" and everything else id still there, IE the cookie has NOT been destroyed. The baffling part is, to debug I printed out the cookie on the thankyou page, and it says the value is null. Ideas?

Thanks

Scott
 
hi,
use javascript to destroy the cookie...

before the </head> tag of your page paste this code

<script>
document.cookie='data=';
</script>

is this a secure site? If yes, then change this code to

<script>
document.cookie='data=;secure';
</script>

this should remove the cookie

san.
 
When you say you are going back to add somethign to your cart, if you are hitting the back button the browser has cached the old stuff. Refresh the page by hitting the shift key and see if things get removed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top