Query regarding sessions
Posted: Sun Jan 17, 2010 4:33 pm
Hi,
I've a question regarding sessions, specifically declaring a variable in one php script and accessing it in another. The problem I'm facing is that the variable isn't recognised by the second php script.
test1.php
output
test2.php
output
php.ini:
register_globals Off Off
By echoing the session_id() I can confirm the same session exists in both scripts.
Any ideas whey $_session['name']; isn't identified in test2.php? Thanks in advance.
I've a question regarding sessions, specifically declaring a variable in one php script and accessing it in another. The problem I'm facing is that the variable isn't recognised by the second php script.
test1.php
Code: Select all
<?php
session_start();
$_session['name']="tom";
echo $_session['name'];
?>
Code: Select all
tomCode: Select all
<?php
session_start();
echo $_session['name'];
?>
Code: Select all
Notice: Undefined variable: _session in /Applications/MAMP/htdocs/test2.php on line 3register_globals Off Off
By echoing the session_id() I can confirm the same session exists in both scripts.
Any ideas whey $_session['name']; isn't identified in test2.php? Thanks in advance.