I am writing some code for a login system for a non-commercial dojo I train at.
I have the whole program written, except that I can't get the $_SESSION array to pass things from page to page.
Below is some test code. Since the test code doesn't access any databases, and was gotten direct off of php.net, I can only assume that there is some setting in the PHP.ini file that needs to be tweaked so that I can pass Session variables from page to page.
Could you please advise me what settings to try and tweak so that this will work?
Code: Select all
<?php
// page1.php
session_start();
echo '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>';
?>nothing.
Code: Select all
<?php
// page2.php
session_start();
echo '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="page1.php">page 1</a>';
?>1969 12 31 19:00:00
Also I have no idea why it outputs 1969...lolz.
Could you please advise me what settings to try and tweak so that this will work with the server environment I am using?
Me and my Dojo thank you,
Evan Jerkunica