I implemented a cookie that works on the local server but does not work on the remote server, I do not understand why. Thanks for any help. I have the following code:
<?php
if (isset($_POST['name']) && !empty($_POST['name'])) {
$firstName = ucwords($_POST['name']);
setcookie('Cookie', $firstName, time() + 60 * 60 * 24 * 30);
insertData($firstName);
$last = mysqli_insert_id($db);
?>
<h1>Hello, <?php echo $firstName; ?>! How are you?</h1>
<form action="" method="POST">
<input id="email" name="email" type="text" value='' autofocus="autofocus">
<input name="id" type="hidden" value="<?php echo $last; ?>">
<input name="name2" type="hidden" value="<?php echo $firstName; ?>">
<button name='submit2' type="submit"></button>
</form>
<?php
}
else if (isset($_POST['submit2'])) {
$mail = $_POST['email'];
$last = $_POST['id'];
$firstName = $_POST['name2'];
updateData($mail, $last);
?>
<h1>Awesome, <?php echo $firstName; ?>. I’ll keep you updated.</h1>
<?php }
else if (isset($_COOKIE['Cookie'])) { ?>
<h1>Hi, <?php echo $_COOKIE['Cookie']; ?>. Welcome back.</h1>
<?php }
else { ?>
<h1>Hello, my name is Lisa.</h1>
<form id="form1" action="" method="POST">
<input id="name" name="name" type="text" autocomplete="off" autofocus="autofocus">
<button id="button1" type="submit"></button>
</form>
<?php } ?>