I'm currently implementing some stuff with session & cookies, but the cookies aren't stored on my computer. Accordingly the session could not be retrieved.
session_start(); // returns true
var_dump($_SESSION); // array(0) {}
var_dump($_COOKIE); // array(0) {}
$_SESSION['test'] = 5;
setcookie('aaa', '111', strtotime('+30 days'));
die;
Reloading the page should display non-empty arrays. But they are always empty. Also there is no cookie displayed on the cookies-tab in Firebug. I use another domain on the same server that works fine with sessions.
Any ideas?
Be sure not to have any output before calling any functions that make use of headers. So try this instead:
<?php
session_start();
$_SESSION['test'] = 5;
setcookie('aaa', '111', strtotime('+30 days'));
var_dump($_SESSION);
var_dump($_COOKIE);
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With