0
I have a modal window that opens, shows the option to click another button, that says yes or no.
If I click yes, I intend to destroy the PHP session.
How can I do this within the jQuery code that opens the modal window?
JQUERY:
$(document).ready(function(){
$('#modalLogout').click(function(){
$('#yes').click(function(){
// preciso de destruir a sessão <?php session_destroy(); ?>
});
});
});
I tried to use:
$(this).load("destroy.php");
And send to a PHP page but it didn’t work!
Here it didn’t work, it redirects to Destroy.php but when I return to the page the session is still active... I also noticed that if I insert <?php session_destroy(); ? > inside the link of the modal button it destroys the session, but that can not be because it is in a place where I can not do it, because it will implicate me in another part of the code, so I wanted inside the jquery.
– Luis
So you are not destroying the session, you can share that file?
– user3603
<?php session_destroy(); header("Location: ../index.php"); ?>
– Luis
And how you redirected to this page in your Javascript?
– user3603
I followed your example above adding the window.Location = "Destroy.php" to my jquery code
– Luis
And you were redirected? You even uploaded the file
destroy.php
? You don’t need to put thesession_start()
before calling thesession_destroy()
?– user3603
I solved the problem with your example, the PHP session was not properly set, so the Destroy.php page did not work!
– Luis