|
Posted by Jerry Stuckle on 09/26/03 11:37
Fernando Rodríguez wrote:
> 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
>
>
if (isset($_COOKIE['CookieTest'] && $_COOKIE['CookieTest'] == 't') ...
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|