p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: testing for enabled cookies question


Message #1 by "carl" <Carl929380262@a...> on Sun, 1 Jul 2001 01:53:13
Hi,

Can anyone tell me of a way to test whether cookies are enabled or not on 

a browser.  I know that if cookies are not enabled, then the HTTP_COOKIE 

variable should contain the empty string, which is what I was trying to 

test for in the code below:



    if ($HTTP_COOKIE AND $HTTP_COOKIE == "")

    {echo "please enable cookies"};



I cannot see why this should be a problem. Any suggestions, Thanks

Message #2 by "7stud" <7stud@e...> on Sun, 1 Jul 2001 19:14:58
Hi,



Why wouldn't the HTTP_COOKIE variable contain an empty string if cookies 

were enabled, but you hadn't set a cookie?



Message #3 by "J House" <jesse@s...> on Tue, 3 Jul 2001 18:36:21
this might work for you.



if (empty($my_cookie))

{

  echo "cookie is not set";

}
Message #4 by "carl" <Carl929380262@a...> on Wed, 4 Jul 2001 14:15:18
> this might work for you.

> 

> if (empty($my_cookie))

> {

>   echo "cookie is not set";



Thanks, that has worked a treat.


  Return to Index