I have two files index.php (first) and second booking.php (second) ,what I want is when someone moves from booking .php to index.php session gets destroyed.
What I have tried so far is ,destroying session with ajax
Here is my relevant code in booking.php file
$(window).on("popstate", function (event, state) {
$.ajax({
type: 'GET',
url: 'logout.php',
async:yes,
success: function(msg) {
if (msg == 'loggedOut') {
window.location.href = 'index.php';
}
}
});
});
And here is my logout.php file
<?php
session_start();
session_destroy();
echo "loggedOut";
?>
Is there any possible way to do above thing I mentioned and if yes then where I should my ajax code ,in booking.php or index.php ! Thanks in advance