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

How to delete bloody cookie?

Status
Not open for further replies.

alfalf

Programmer
Joined
Mar 6, 2003
Messages
155
Location
BA
Hello.

How to kill cookie?

I know that cookie can be deleted (must be deleted) with same parameters as they were set with it. And also other stuff about cookies (not visible until reloaded page, blah blah.)
I have IE5.0, on W2K, together with Apache2, PHP4. My cookie option in browser is set properly (do receive cookies), cookie do become visible, and I perfectly read value in it, but simply cannot kill it.

But.
I'm really having problems NOT only to delete cookie, but to set new value in it. Discusting!
Must say that I lost my patience.
Everything works fine with javascript but PHP solutions giving me a real headache as if I'm completely stupid.

If anyone can point me to an simple example that shows how to kill an set cookie, or to change its value, mui obligar!
Thanks in advance.

CODE THAT setcookie():
<?php
if (isset($_COOKIE['main_s']))
{
$main_s=$_COOKIE['main_s'];
}
else
{
/* one year cookie*/
setcookie ('main_s', '1 25 36 9001 1 0 0', 31536000);
$main_s=$_COOKIE['main_s'];
}
?>
CODE THAT READS IT:
<?
print '<pre>';
$aCValue= $_COOKIE;
print_r ($aCValue);
if(isset($_COOKIE_['direction_s'])) {
$direction_s=$_COOKIE['direction_s'];
}
if(isset($_COOKIE['main_s'])) {
$main_s=$_COOKIE['main_s'];
}
echo $main_s.&quot;<br>&quot;;
$a=explode(&quot; &quot;, $main_s);
echo $a[0].&quot;<br>&quot;;
echo $a[1].&quot;<br>&quot;;
echo $a[2].&quot;<br>&quot;;
echo $a[3].&quot;<br>&quot;;
echo $a[4].&quot;<br>&quot;;
echo $a[5].&quot;<br>&quot;;
echo $a[6].&quot;<br>&quot;;
?>

KILLING COOKIE CODE:
<?php
setcookie ('main_s', '1 25 36 9001 1 0 0', -31536000);
?>



Tststs!
 
I think you should try

Code:
<?php
setcookie('main_s', &quot;&quot;, time()-1);
?>

Hope it helps,
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top