Re: Problems with Set Cookie
| From: | Tyler Longren | Date: | Mon, 11 Sep 2000 14:30:41 +0000 |
| Subject: | Re: Problems with Set Cookie | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16158@lists.php.net to get a copy of this message | ||
I was getting those lastnight. Just put that piece of code before the
<html> part of your site. that should fix it.
Regards,
Tyler Longren
----- Original Message -----
From: "Ian LeBlanc" <ian@rask.com>
To: "karl Alderson" <karl@griffindirectories.com>
Cc: <php-general@lists.php.net>
Sent: Monday, September 11, 2000 5:25 AM
Subject: [PHP] Problems with Set Cookie
> 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).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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>