You are here: Re: Testing the presence of a given cookie « PHP Programming Language « IT news, forums, messages
Re: Testing the presence of a given cookie

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация