Recently, I was trying to implement logout functionality while working with PHP website. I had put logout logic in logout.php file and I was calling that file on the click of logout link like following:
I investigated two approaches to accomplish my task.
<a href="logout.php" onclick="ClearMyLocalStorage()">
And in your function you have to write like
window.location.href = 'logout.php';