Stefan, 

What would the CGI binary be named? It was my ISP who pointed me to
use #! /usr/local/bin/php and specify "Content-type...". So are they
telling me to make my own headers already there? It used to work
before they upgraded to 4.3.4. Should they have compiled it
differently? My code is inserted at the bottom.

As I said, cookies are okay as .php file and broken as .cgi file. I
copied the headers generated by the .php file and printed them in the
.cgi file. The one line I added was 

print 'Set-Cookie: TestCookie=hey+cookie%21' . "\n";

being the header equivalent of 

$value = "hey cookie!"; setcookie("TestCookie", $value);

But even going through all this, the $_COOKIE variable in the .cgi
file is still only an empty array.


Greetings, 
Børge

P.S. Stefan, Vielen Dank für Deine Hilfe!

> Don't use the CLI binary for CGI purposes. If you do, you have to take
> care of the headers yourself, like print 'Set-Cookie:
> something-with-your-session-data'... and you don't want that.
> use the CGI binary if you want to use PHP as cgi.
> -- 
> Regards,
> Stefan Walk
> <[EMAIL PROTECTED]>
> 

Here's my .cgi code:
#! /usr/local/bin/php
<?php

// $value = "hey cookie!"; setcookie("TestCookie", $value); // .php file
print 'Set-Cookie: TestCookie=hey+cookie%21' . "\n"; // .cgi file
print 'Content-Type: text/html' . "\n\n"; // required in .cgi file

    print '<html><body>' . "\n";
    echo $_COOKIE["TestCookie"];
    echo 'was there a cookie?';
    echo '<br>---<br>';
    print_r($_COOKIE); // returns "Array ()"
    echo '<br>---<br>';

    print '</body></html>' . "\n";
?>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to