Hey, whenever i set a cookie to a value retrieved from my database, it expires instantly, regardless of how long i set the time parameter.
my code is below.
<?php
if(isset($_COOKIE['A001'])) {
$sessionID = $_COOKIE['A001'];
$con = [code removed however I have checked that the connection is fine]
$sql = "SELECT * FROM Users WHERE SessionID = '$sessionID' ";
if($result = mysqli_query($con, $sql)) {
$row = mysqli_fetch_assoc($result);
setcookie("LName", $row['LastName'], time() + 1800, "/", "www.mywebsite.com");
}
}
mysqli_free_result($result);
mysqli_close();
?>
Cookie A001 is set in another file and the code does detect this file and verifies its contents.
The cookie LName is set after this code is run but its expiry date is identical to its creation date and so its contents say ādeletedā when i look at it in the browser.
This only occurs if the cookies value is set to either $row[ācolumn_nameā] or another variable which is set to $row[ācolumn_nameā]