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



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to