I just come across a strange problem today using xampp-portable (1.8.1). In php files which are not on the same drive of xampp-portable installation, it cannot access PHP Session.
My xampp-portable is installed at D:\Soft\xampp-portable, and my DocumentRoot is C:\www.
I put two files a.php and b.php in C:\www.
a.php
- Code: Select all
<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
// this starts the session
session_start();
// this sets variables in the session
$_SESSION['color']='red';
$_SESSION['size'] ='small';
$_SESSION['shape']='round';
echo "Done";
echo "Our color value is ".$_SESSION['color'];
echo "Our size value is ".$_SESSION['size'];
echo "Our shape value is ".$_SESSION['shape'];
?>
b.php
- Code: Select all
<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
// this starts the session
session_start();
$_SESSION['color']='green';
// echo variable from the session, we set this on our other page
echo "Our color value is ".$_SESSION['color'];
echo "Our size value is ".$_SESSION['size'];
echo "Our shape value is ".$_SESSION['shape'];
?>
Output of a.php
- Code: Select all
Warning: session_start(): open(\Soft\xampp-portable\tmp\sess_ihp85uslaj309f6ll21uipnc82, O_RDWR) failed: No such file or directory (2) in C:\Users\Peter\Documents\workspace-sts-3.1.0.RELEASE\test-session\a.php on line 6
DoneOur color value is redOur size value is smallOur shape value is round
Output of b.php
- Code: Select all
Warning: session_start(): open(\Soft\xampp-portable\tmp\sess_ihp85uslaj309f6ll21uipnc82, O_RDWR) failed: No such file or directory (2) in C:\Users\Peter\Documents\workspace-sts-3.1.0.RELEASE\test-session\b.php on line 6
Our color value is green
Notice: Undefined index: size in C:\Users\Peter\Documents\workspace-sts-3.1.0.RELEASE\test-session\b.php on line 12
Our size value is
Notice: Undefined index: shape in C:\Users\Peter\Documents\workspace-sts-3.1.0.RELEASE\test-session\b.php on line 13
Our shape value is
After I moved DocumentRoot from C:\www to D:\www, everything goes well.
So I guess all web directories must be on the same drive where xmapp-portable is installed. Is that true?
Thanks,
Peter