Checking cookie using if isset and then deleting it
Posted: Mon May 25, 2009 3:58 am
Hi guys,
I'm new here so 'hello'
I have a question about checking a client cookie using if isset() and then destroying the cookie.
Given a cookie called "cookiename", I check it like this:
Which is working fine. But, then a few lines later when I have loaded the cookie value into a variable, I delete the cookie using:
This overwrites the cookie with blank data, but *the cookie still exists*.
Will if (isset($_COOKIE['cookiename'])) return true because the cookie still exists? Even though the value is blank?
It appears to be working fine (ie, the cookie is not being read once overwritten), but I just want to be sure....! Do I need to add another conditional after if isset (for example IF the cookie is set OR the cookie value is null) or is what I am doing ok?
Many thanks,
Martin
I'm new here so 'hello'
I have a question about checking a client cookie using if isset() and then destroying the cookie.
Given a cookie called "cookiename", I check it like this:
Code: Select all
if (isset($_COOKIE['cookiename']))Code: Select all
setcookie('cookiename');Will if (isset($_COOKIE['cookiename'])) return true because the cookie still exists? Even though the value is blank?
It appears to be working fine (ie, the cookie is not being read once overwritten), but I just want to be sure....! Do I need to add another conditional after if isset (for example IF the cookie is set OR the cookie value is null) or is what I am doing ok?
Many thanks,
Martin