I have this code which sets the cookies:
$root = $_SERVER['DOCUMENT_ROOT'] . '/account_share';
include_once $root . '/php/objects/user.php';
if (session_status() == PHP_SESSION_NONE)
{
session_start();
}
$user = unserialize($_SESSION['user']);
setcookie('email', $user->getEmail(), time()+3600*24*365); //year
setcookie('pass', encrypt($user->getPassword()), time()+3600*24*365); //year
$response = Array();
if(isset($_COOKIE['email']) && isset($_COOKIE['pass']))
{
$response['response'] = 'success';
}
else
{
$response['response'] = 'error';
}
echo json_encode($response);
Here the respone is 'success' - the cookies are set.
And then I have this code which I try to run after the cookies are set:
if (session_status() == PHP_SESSION_NONE)
{
session_start();
}
var_dump($_COOKIE);
Here i'm getting this result after the dump:
array(1) { ["PHPSESSID"]=> string(26) "6i2n4tptlhi39f0mglc9v8ab23" }
I have also checked my cookies in the chrome settings and could not find them.
NOTE:
I am using (for now) xampp on my local pc.
So what is wrong with what I have done?!