I have a form on page 1:
<form method="post" action="request-form">
<input type="text" id="amzQry" name="item" placeholder="What do you need?" autocomplete="on">
<input id="autocomplete" name="destination" placeholder="where? (e.g. Buenos Aires)" onfocus="geolocate()" type="text" required="" aria-required="true" autocomplete="off">
<button type="submit" value="" >submit</button>
</form>
I want this information to be stored on an ongoing basis, so that even if the user subsequently logs in (in this case joomla), these cookies will be persistent and may be called up. This is why I used cookies, not sessions in this case. Correct me if this is not the right way to do this.
I have the code to set and receive a cookie on page 2:
<?php
$itemcookie = $_POST['item'];
$detsinationcookie = $_POST['destination'];
setcookie( "itemcookie", $itemcookie, strtotime( '+30 days' ) );
setcookie( "destinationcookie", $detsinationcookie, strtotime( '+30 days' ) );
?>
But the cookie data does not appear on the second page when loading after submitting the form. If I refresh the second page, the data appears in the right places, that is, where I called it, for example,
<?php echo $_COOKIE["itemcookie"]; ?>
How to get cookie data right on page 2?
larpo