|
Posted by Fernando Rodrνguez on 09/25/16 11:37
Hello windandwaves,
>> How do I test if a user has a given cookie? O:-)
>>
>> Thanks
>>
> Here is how I do it:
>
> //set the cookie:
> setcookie("CookieTest", "t");
> //test of the cookie exists (can only be done in the next page / load)
> if($_COOKIE["CookieTest"] == "t") {
> echo "cookie exists";
> }
Thanks it works. However, if the cookie doesn't exist, I get a warning on
the rendered page similar to this one:
Notice: Undefined index: aTestCootie in c:\proyectos\websites\test\action.php
on line 13
That's great for debugging, but how do Iavoid this from showing up in production
code?
Thanks
Navigation:
[Reply to this message]
|