I have a problem with html headers using sessions. I guess it has to do with the Content-type line. My ISP uses PHP 4.3.4 with register_globals = On (although I want this to work with Off too).
My program (test3.cgi, test3.php) simply logs the number of times I have accessed a web site. As a php file it works as supposed to only that there's no Content-type line. As a .cgi file the script has to have the Content-type line in order to be executed. With Content-type BEFORE session_start(), $_SESSION doesn't seem to be set. Alternatively, with Content-type AFTER session_start(), I get "Warning: session_start(): Cannot send session cookie - headers already sent by..." Do you have any ideas what I should do to make both .php and .cgi versions work? -- Børge Here's test3.cgi: ====================================================== #! /usr/local/bin/php <?php print 'Content-type: text/html' . "\n\n"; session_start(); print '<html>' . "\n"; print '<body>' . "\n"; print 'This is the test3.cgi file<br>' . "\n"; if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { $_SESSION['count']++; } print 'This is your visit number ' . $_SESSION['count'] . "\n"; print '</body>' . "\n"; print '</html>' . "\n"; ?> ====================================================== And test3.php: ====================================================== <?php session_start(); // print 'Content-type: text/html' . "\n\n"; // only in .cgi version! print '<html>' . "\n"; print '<body>' . "\n"; print 'This is the test3.php file<br>' . "\n"; if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { $_SESSION['count']++; } print 'This is your visit number ' . $_SESSION['count'] . "\n"; print '</body>' . "\n"; print '</html>' . "\n"; ?> ====================================================== -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php