PHP session being wiped when AJAX call made?
I've got the following PHP session on a page, the session being created based on a POST from a previous page/form.
<?php
@session_start();
if ("" === "") {
$_SESSION["EDITeventID"] = "".((isset($_POST["eID"]))?$_POST["eID"]:"") ."";
}
?>
This loads an event's record from the database. I'm using AJAX also on this page, which displays records from a database as a user types text into a search field, the idea being that the user can change the venue for this event by selecting a matching record.
AJAX displays the results from the database as expected and I've coded on a "Select" form/button so that the user can select one of the returned values. Clicking select reloads the page, but with the new venue's details.
However when the page reloads it wipes the session value so the event data no longer shows and I can only attribute this to the AJAX call.
This is the form...
<input type="text" class="form-control" name="search" id="search" placeholder="Search for venue..." maxlength="50" required>
<div id="display"></div>
This is the AJAX....
<?php
include "db.php";
if (isset($_POST['search'])) {
$Name = $_POST['search'];
$Query = "SELECT TradVenue.venueID, TradVenue.venueNAME, TradVenue.venueCITY, TradVenue.venueREGION, NJcountries.countryNAME FROM TradVenue INNER JOIN NJcountries ON TradVenue.venueCOUNTRY = NJcountries.countryID WHERE venueName LIKE '%$Name%' OR venueCITY LIKE '%$Name%' LIMIT 15";
$ExecQuery = MySQLi_query($con, $Query);
echo '
<ul class="list-unstyled">
';
while ($Result = MySQLi_fetch_array($ExecQuery)) {
?>
<li>
<ul class="list-inline">
<li class="list-inline-item"><?php echo $Result['venueNAME']; ?>, <?php echo $Result['venueCITY']; ?>, <?php echo $Result['countryNAME']; ?></li>
<li class="list-inline-item"><?php echo "<form action='change_venue.php?v=1' method='post' class='form-inline'>"; ?>
<?php echo "<input type='hidden' value='"; ?><?php echo $Result['venueID']; ?><?php echo "' name='vID'>"; ?>
<?php echo "<button type='submit' class='btn btn-sm btn-success mt-2 mb-2' name='BTNsearchvenue'>Select</button>"; ?>
<?php echo "</form>"; ?></li>
</ul>
</li>
<?php
}}
?>
</ul>
Is there something I can add in the AJAX code that will maintain the PHP session value throughout this process?
Thank you.
NJ