How do I set unlimited time to a cookie for a session? I have tried the following below but I still get undefined index notices on my sessions after a day:
setcookie('idcourse', 'CourseID', 9999999999);
setcookie('namecourse', 'CourseName', 9999999999);
setcookie('id', 'ID', 9999999999);
if (isset($_POST['idcourse'])) {
$_SESSION['idcourse'] = $_POST['idcourse'];
}
if (isset($_POST['namecourse'])) {
$_SESSION['namecourse'] = $_POST['namecourse'];
}
if (isset($_POST['id'])) {
$_SESSION['id'] = $_POST['id'];
}
You must add an expiry date, or the cookie will act like a session and expire when you leave the website,
what you’re doing is nearly right but you need to change it slightly;
You are setting expire 9999999999 (you need to specify a UNIX TIMESTAMP in the future), so i use the following:
will make the cookie expire in 2 months, you can increment this accordingly.