Hi,
I'm new to php and want to test whether cookies are enabled in a browser. I'm setting a cookie on my first page and then I'm checking whether it is set or not by
<?php
if (!isset($_COOKIE['test']))
{
echo ("Please enable cookies in your browser to change the style of the web site");
}
?>
....on the same page it is not recognizing the cookie, even though when I see in the stored cookie list of the browser , my cookie exists there. But if I refersh the page then this above script is recognizing the cookie. I tried to use auto refresh function of html but it sets a infinite loop for Netscape and Mozilla browser.... I don't want to use Javascript for this purpose.
My cookie set script is :
<?php
ob_start();
$a=0;
$a++;
header("Set-Cookie: test=$a; path=/; domain=sci.tamucc.edu; expires=".gmstrftime("%A, %d-%b-%Y %H:%M:%S GMT", time()+10800));
?>
This script work fine....Its is on the very first line of the page....and I have tried this script without ob_start() but there is no difference in my result....
Thanks
Himanshu