PHP4 - Can't generate Session

G

Guest

Guest
Hello all,

I recently configured and built Apache and PHP for my PHP development. My build is apache_1.3.27 and php-4.2.3 on Solaris 8 and RedHat Linux 7.2 There seems to be something spooky with session as this does not appear to work. In my scripts, attempt to retrieve session variables fails despite the fact that these variables where registered and assigned values correctly.

I download a script shown below(indented), which should instantiate a counter and increase on each page refresh via the browser menu. This does not work and no session is instantiated.

>><?php
>>session_start();
>>session_register("SESSION");
>>
>>if (! isset($SESSION)) {
>> $SESSION["count"] = 0;
>> echo "<li>Counter initialized, please reload this page to see it >>increment";
>>} else {
>> echo "<li>Waking up session $PHPSESSID";
>> $SESSION["count"]++;
>>}
>>echo "<li>The counter is now $SESSION[count] ";
>>?>

Any suggestions on how to overcome this predicament would be welcome.

Regards,

Deathr0w67
 
Try this instead:
Code:
<?
session_start();
$_SESSION['count'] = (@$_SESSION['count'])? $_SESSION['count']++:0;
print "The counter is ".$_SESSION['count'];
?>
 
Back
Top