$_SESSION not storing values?
Posted: Thu Apr 17, 2008 7:26 am
Hi
Basically I'm trying to store some vars in the session, now I can write to the session on the www domain, but this is on a subdomain (not sure if that makes a difference).
code is like this, although i've re-written only the pertinent bits.
index.php
Class.php
test.php
The error returned is
Notice: Undefined index: info in /home/vhosts/dev/test.php on line 4
Notice: Undefined index: lan in /home/vhosts/dev/test.php on line 5
I've done a var_dump of the $_SESSION on each page. On index.php it has all the information it should do. On test.php it's empty. I've checked the session files on the server and although the file is created no information is written to it.
PHP Version is 5.0.4 (upgrading at this time isn't an option).
This is really confusing me. Can anyone shed any light?
Basically I'm trying to store some vars in the session, now I can write to the session on the www domain, but this is on a subdomain (not sure if that makes a difference).
code is like this, although i've re-written only the pertinent bits.
index.php
Code: Select all
<?php
session_start();
require_once('lib/Class.php');
$test = new Class();
header('location: test.php');
die();
?>
Code: Select all
<?php
class Class {
public function __construct(){
//do some stuff that returns an array and a string
$_SESSION['info'] = serialize($array);
$_SESSION['lan'] = $string;
}
?>
Code: Select all
<?php
$info = unserialize($_SESSION['info']);
$lan = $_SESSION['lan'];
?>
Notice: Undefined index: info in /home/vhosts/dev/test.php on line 4
Notice: Undefined index: lan in /home/vhosts/dev/test.php on line 5
I've done a var_dump of the $_SESSION on each page. On index.php it has all the information it should do. On test.php it's empty. I've checked the session files on the server and although the file is created no information is written to it.
PHP Version is 5.0.4 (upgrading at this time isn't an option).
This is really confusing me. Can anyone shed any light?