Hey guys, I'm rather new to PHP and sessions. I've actually never worked with them before and I'm having quite a few problems working with them with AJAX over a subdomain.
I'm on http://www.example.com/whatever and I'm setting the cookie with:
session_set_cookie_params(0, '/', '.example.com');
session_start();
if(!isset($_SESSION['password']) ) {
$_SESSION['password'] = $_POST['password'];
}
var_dump(ini_get_all('session')); //seems like it doesn't save the cookie???
Then I'm using jQuery (load()
) to reload a certain part of the page. I'm loading somefile.php from http://subdomain.example.com/subdomain/somefile.php. I want to retrieve the session information inside this somefile.php. I'm using
var_dump(ini_get_all('session')); //can't find the cookie!??
if(isset($_SESSION['password']) ) {
$user_pass = $_SESSION['password'];
echo "Password: " . $user_pass . "<br>";
} else {
print "can't find cookie!";
}
But I can't get the information! Any idea what I could have done wrong? Did I miss anything?