Serious problem with setcookie
| From: | Ian LeBlanc | Date: | Fri, 08 Sep 2000 20:21:03 +0000 |
| Subject: | Serious problem with setcookie | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15953@lists.php.net to get a copy of this message | ||
I have a problem with my set cookie function:
Here is the code (all of it)
#!/usr/local/bin/php
<?
if (! $SID) {
if (! $SessionID) {
// Check for a SessionID cookie, and assign one if needed
$temp1=date("U");
$temp2=getmypid();
$SessionID="Zappy_".strval($temp1).strval($temp2).str $SessionID="Zappy_".strval($temp1).strval($temp2).strval(Rand()%1000);
$timeid=time()+60*60*24;
// $path_str = getenv("HTTP_HOST");
// Cookie is date + process number + random number
// Cookie will expire in one day (60 sec * 60 min * 24 hours)
SetCookie("SessionID",$SessionID,time()+60*60*24,"/");
// header("Set-Cookie:SessionID=$SessionID;domain=$path_str;expire=$timeid;path =/");
}
} else {
$SessionID = $SID;
}
// END OF COOKIE CHECK
?>
ERROR I get is....
"sorry header has allready bene sent'
This works on another server I have.
One running on PHP Version 3.0.12 - works
One running on PHP Version 3.0.15 - failed
the one on PHP Version 3.0.12 does not need the #!/usr/local/bin/php part is just runs php, and php3 (plus what ever i tell it to parse in the .htaccess file)
the one running Version 3.0.15 does need the #!/usr/local/bin/php at the top.. why I do not know. it is just what costomer support told me to use to have the server parse a php page. when it is not used the server does not parse the php in teh scripts and will only read the html.
like stated above issue is i can run PHP on both servers.. i can setcookie with that script i provided on the first but not the second.
the second one give me the "header allready sent..'
any ideas.
Regards,
Ian LeBlanc
Senior Internet Technician
Rask, Inc. - www.rask.com
Phone: (727) 517-2000
Fax: (727) 517-2001