Hi. Im very new to php, and I have a problem here that I cant find the
solution for. I have problems with session variables, I want some
variables to maintain their value between different php script that is
being called. I have read the online manual, and here is an example from
it that doesnt work for me, it illustrates very well my problem.
File 1, index.php
<?php
// index.php
session_start() ;
echo '<br />Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
// Works if session cookie was accepted
echo '<br /><a href="page2.php ">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php ?' . SID . '">page 2</a>';
?>
File 2, page2.php
<?php
// page2.php
session_start() ;
echo '<br />Welcome to page #2<br />';
echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);
// You may want to use SID here, like we did in page1.php
echo '<br /><a href="index.php ">page 1</a>';
?>
I get no output, except the date which shows 1970 bla bla
I have apache 2.0.48, PHP 4.3.3 running on a Redhat 9.0 box. I have not
touched the register_global s in php.ini, it's Off. What can be the problem
here ? Any help would be much appreciated, I'm stuck....
Thanx
/ZoombyWoof
solution for. I have problems with session variables, I want some
variables to maintain their value between different php script that is
being called. I have read the online manual, and here is an example from
it that doesnt work for me, it illustrates very well my problem.
File 1, index.php
<?php
// index.php
session_start() ;
echo '<br />Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
// Works if session cookie was accepted
echo '<br /><a href="page2.php ">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php ?' . SID . '">page 2</a>';
?>
File 2, page2.php
<?php
// page2.php
session_start() ;
echo '<br />Welcome to page #2<br />';
echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);
// You may want to use SID here, like we did in page1.php
echo '<br /><a href="index.php ">page 1</a>';
?>
I get no output, except the date which shows 1970 bla bla
I have apache 2.0.48, PHP 4.3.3 running on a Redhat 9.0 box. I have not
touched the register_global s in php.ini, it's Off. What can be the problem
here ? Any help would be much appreciated, I'm stuck....
Thanx
/ZoombyWoof
Comment