cookie problems...

From: Date: Wed, 04 Sep 2002 14:56:23 +0000
Subject: cookie problems...
Groups: php.windows 
Request: Send a blank email to php-windows+get-15665@lists.php.net to get a copy of this message
Hello all, I seem to be having problems with getting cookies to set correctly. I use the following code: ___________________________________________________ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=1, pre-check=1", false); header("Pragma: no-cache"); setcookie("User", $_POST['user']); setcookie("FirstName", $row["first_name"]); setcookie("LastName", $row["last_name"]); setcookie("Ext", $row["EXT"]); setcookie("Department", $row["dept"]); \\and to display it: <TABLE border = 1> <TR> <TH>First Name:</TH> <TH>Last Name:</TH> <TH>Extension:</TH> <TH>Department:</TH> </TR> <TR> <TD><?=$_COOKIE['FirstName']?></TD> <TD><?=$_COOKIE['LastName']?></TD> <TD><?=$_COOKIE['Ext']?></TD> <TD><?=$_COOKIE['Department']?></TD> </TR> </TABLE> ___________________________________________________ The problem it that the cookie does not set itself the first time the page is loaded. It gives the following error: Notice: Undefined index: FirstName in c:\inetpub\wwwroot\helpdesk\menu.php on line 37 Once you hit the reload button it works fine. And if the cookie is set and the user logs back into the page with a different user name then the old info is still set in the cookie until you hit the reload button. Thanks for the help! -Nick

« previous php.windows (#15665) next »