I am trying to write a menu system for my website based around an include file. That way, all I need to do edit one menu for it to appear on all pages. I would like to show the user where they are by placing a marker next to appropriate entry in the menu. Since there may be more than one user at any one time then cookies would appear to be useful. However, I am still having problems.
<?php
if (!($HTTP_COOKIE_VARS["Counter"])){
setcookie ("Counter",1,time()+1800);
}
echo ("Counter contains : ");
echo ($HTTP_COOKIE_VARS["Counter"]);
?>
<html>
<head>
<title>menu test using cookie</title>
</head>
<body>
<H1>The cookie has been read</H1>
</body>
</html>
I want to check to see if the cookie has been set and if not then set it equal to 1 i.e. the first menu item. That way, all new users always start at the first item. The bad news is that I need to run the above script twice before I see any changes. Does the script need to reload itself so that it skips the initial question second time? If so, does anybody know how to do it?
Thanks,
Ian