I would like it so that when someone presses a certain link that by using ajax it will run a php file to destroy a session and when its a success the current page will remove an item from Local Storage and then the page will redirect to the index page.
currently have the following but it doesn't work
JQUERY
$('#key a').click(function(e) {
e.preventDefault();
$.ajax({
type:"POST",
url:"/assets/inc/sign-out.php",
data:'',
dataType:'html',
context:document.body,
global:false,
async:false,
success:function(data){
console.log(data);
localStorage.removeItem("logged");
window.location.replace('/');
}
});
});
PHP
<?php
include('config.php');
session_destroy();
?>
config.phpbut there should be asession_start()beforesession_destroy()