Deleting first item of a $_COOKIE array

Posted by Mike Burke on Stack Overflow See other posts from Stack Overflow or by Mike Burke
Published on 2010-03-26T21:35:03Z Indexed on 2010/03/26 21:43 UTC
Read the original article Hit count: 313

Filed under:

if I add an item to the $_COOKIE array as such:

setcookie("favorites[]", "value",  time()+3600);   

I can delete any item from the $_COOKIE[favorites] array like this:

setcookie("favorites[$deletekey]", "", time()+3600);  

EXCEPT the first one added so this does not work:

setcookie("favorites[0]", "", time()+3600*24);  

How can I delete the first one and leave others intact?

© Stack Overflow or respective owner

Related posts about php