Button on index
page:
$('#killsession').click(function() {
$.get('killsession.php');
alert("OK");
});
killsession.php
:
<?php
session_start():
session_destroy();
?>
After killing the session with this button, any session-esque related functions on index
still work (session variables are still set/exist). For example, I have a counting session variable that is incremented when I click a certain button. This counting variable does not lose its spot in counting after killing the session.
Is it possible to kill a session with a JQuery button?
All the PHP session items are loaded when the page is first loaded. They are still in the page/browser memory as long as the page is open. You need to reload the page after killing the session. You can do this with javascript window.location.href = window.location.href
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With