Jump to content

Deleting a Cookie that stores an array


locknuts

Recommended Posts

I have created a cookie, which stores an array in a cookie.

 

  foreach($dk as $key => $value){

        setcookie("tart[$value]", $dv[$key], "", "/"); 

  }

 

This works fine....(note $value is not numeric)

I then retrieve the values in the same page when reloaded as follows...

 

    foreach ($_COOKIE['tart'] as $key => $value) {

$dray[$key] = $value;

    }

 

This works fine too... :)

 

Now the problem is i need to destroy this cookie after the user leaves this

page. So i call a script when the submit button is pressed.

 

The script contains codes that are supposed to destroy the cookie.

 

I've tried.....

 

if (isset($_COOKIE['tart'])) {

    foreach ($_COOKIE['tart'] as $key => $value) {

setcookie("tart[$key]");

}

 

unset($_COOKIE["tart");

 

setcookie("tart", "", -1);

 

setcookie("tart");

 

..... well almost all of the combinations of the above....

 

Must note that (isset($_COOKIE['tart'])) comes up false. why???

 

And i can't seem to find the cookie anywhere i'd expect it to be...

(ie cookie folder or temp internet folder)

 

But the values are still retrieved from somewhere when i reload the original page....

 

They only are destroyed when i close the window and open it again.

 

Am using XP ie6 sp2....apache server...

 

Any advise would be nice.....am running out of ideas here... except for using javascript to deal with the cookies...

 

Link to comment
https://forums.phpfreaks.com/topic/135530-deleting-a-cookie-that-stores-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.