This is a quick question, that has been bugging me for quite some time!
I have a pagewww.example.com/dir/index.php
which sets a $_SESSION
variable. I access this variable again on www.example.com/dir/dir2/dostuff.php
and this works fine!
However, if I set the session through www.example.com/dir/
it isn't set in www.example.com/dir/dir2/dostuff.php
.
I have rewritten the .htaccess with
RewriteRule ^.*\/dir\/$ /dir/index.php [NC]
and set my php.ini in index.php using:
ini_set('session.cookie_domain', '.example.com');
However without results. Does anyone have any suggestions?
Update:
In a nutshell index.php simply runs:
if (!isset($_SESSION)) session_start();
$_SESSION['param'] = "val";
The dostuff.php runs:
if (!isset($_SESSION)) session_start();
echo $_SESSION['param'];