I am setting up a webserver on FreeBSD 9.1 and currently have Apache up and running fine, but for whatever reason I cannot get PHP to remember the session variables' values between pages/refreshes!
I have tried adding php5, php5-extensions, php5-pgsql and php5-pdo_pgsql all through ports as well as through a mixtures of ports (php5), packages (php5-extensions) and forcing when postgresql-client conflicts (php5-pgsql and php5-pdo_pgsql) all to the same effect.
I made these two files for examples:
test1.php
test2.php
It goes to test2.php and I get the following
and every time I refresh the page, I get another (different) session_id() value. So it appears that the session variables and values are not being kept in-between refresh/page directs.
I thought this was something that just works out-of-the-box.
I have tried adding php5, php5-extensions, php5-pgsql and php5-pdo_pgsql all through ports as well as through a mixtures of ports (php5), packages (php5-extensions) and forcing when postgresql-client conflicts (php5-pgsql and php5-pdo_pgsql) all to the same effect.
Code:
php5-5.4.7 PHP Scripting Language
php5-ctype-5.4.7 The ctype shared extension for php
php5-dom-5.4.7 The dom shared extension for php
php5-extensions-1.7 A "meta-port" to install PHP extensions
php5-filter-5.4.7 The filter shared extension for php
php5-hash-5.4.7 The hash shared extension for php
php5-iconv-5.4.7 The iconv shared extension for php
php5-json-5.4.7 The json shared extension for php
php5-pdo-5.4.7 The pdo shared extension for php
php5-pdo_pgsql-5.4.7 The pdo_pgsql shared extension for php
php5-pdo_sqlite-5.4.7 The pdo_sqlite shared extension for php
php5-pgsql-5.4.7 The pgsql shared extension for php
php5-phar-5.4.7 The phar shared extension for php
php5-posix-5.4.7 The posix shared extension for php
php5-session-5.4.7 The session shared extension for php
php5-simplexml-5.4.7 The simplexml shared extension for php
php5-sqlite3-5.4.7 The sqlite3 shared extension for php
php5-tokenizer-5.4.7 The tokenizer shared extension for php
php5-xml-5.4.7 The xml shared extension for php
php5-xmlreader-5.4.7 The xmlreader shared extension for php
php5-xmlwriter-5.4.7 The xmlwriter shared extension for php
I made these two files for examples:
test1.php
Code:
$ cat test1.php
<?php
session_start();
$_SESSION['foo'] = 'bar';
header('Location:test2.php');
?>
test2.php
Code:
$ cat test2.php
<?php
session_start();
echo '
session_id()=' . session_id();
echo '
session_status()=' . session_status();
echo '
$_SESSION[\'foo\'] = ' . $_SESSION['foo'];
echo '
isset($_SESSION) = ' . isset($_SESSION);
echo '
Just in case I missed one';
echo '<ul>';
echo '<li>List of Items</li>';
foreach( $_SESSION as $sname => $svalue ) {
echo '<li>' . $sname . ' => ' . $svalue . '</li>';
}
echo '</ul>';
?>
It goes to test2.php and I get the following
Code:
session_id()=6c830aea7365eca59a962fc056273768
session_status()=2
$_SESSION['foo'] =
isset($_SESSION) = 1
Just in case I missed one
[LIST]
[*]List of Items[/LIST]
and every time I refresh the page, I get another (different) session_id() value. So it appears that the session variables and values are not being kept in-between refresh/page directs.
I thought this was something that just works out-of-the-box.