I have written a very short sessions test program and saved it in both
.cgi and .php formats. I want to run my site as .cgi so that other
users on the same servar can't read my files.

Running as a .php file, everything seems OK. I've set the browser to
prompt for cookies. And it does just that with test4.php.

As a .cgi file, I never get prompted for the cookie. In subsequent
accesses, the isset($_SESSION['count']) is never true. 

Is there an error in the way session_start() is performing header
generation? My ISP uses PHP 4.3.4.

I've tried putting 'Content-type...' in header() and also to place it
before I call session_start(). That doesn't make my program work.

The only differences between the .php and .cgi versions is that
test4.cgi contains #! /usr/local/bin/php and print 'Content-type...'.
The files are included below.

Hope you can help me out on this one!

Regards, 

Børge Strand


test4.cgi:
------------
#! /usr/local/bin/php
<?php
    session_start();
    print 'Content-type: text/html' . "\n\n";  // Required in .cgi
file
    print '<html><body>' . "\n";
    print 'This is the test4.cgi file<br>' . "\n";

    if (!isset($_SESSION['count']))
        $_SESSION['count'] = 1;
    else
        $_SESSION['count']++;

    print 'Your visit number ' . $_SESSION['count'] . "\n";
    print '</body></html>' . "\n";
?>
------------

test4.php:
------------
<?php
    session_start();
    print '<html><body>' . "\n";
    print 'This is the test4.php file<br>' . "\n";

    if (!isset($_SESSION['count']))
        $_SESSION['count'] = 1;
    else
        $_SESSION['count']++;

    print 'Your visit number ' . $_SESSION['count'] . "\n";
    print '</body></html>' . "\n";
?>
------------

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

Reply via email to