PHP Cookies

Hello everybody:
So here is my situation. I am attempting to add an alert to my site which will display the last update date to the user. Now, I do realize this could become pretty annoying for frequent visitors, so I added a checkbox that says: "Do not show this message again." I can check it, and I can click the OK button, but the PHP script which sets a cookie to remember that I checked the box doesn't seem to want to work. Here is the script which the OK button submits to.


<?php
$hide = $_POST['donotshow'];
if(isset($hide)) {
$cookie_name = "user";
$cookie_value = "hide update message";
setcookie($cookie_name, $cookie_value, time() + (86400 * 365), "/");
header('Location: /home.php');
}
else {
header('Location: /home.php');
}
?>

Here is the code of my alert page
<?php
if (isset($_COOKIE[$cookie_name])) {
header('Location: /home.php');
}
else {
}
?>
<html>
<head>
<title>Alert!</title>
<body>
<p>This site was last updated on November 12th, 2019</p>
<form action="" method="post">
<input type="checkbox" name="donotshow" title="Do Not show This Message Again" value="Do Not Show This Message Again">
<br>
<input type="submit" value="OK">
</form>
</body>
</html>

Can anybody see what I'm doing wrong here? Thanks for any and all help.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Thatguy via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Thatguy via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to