Redirect user terminating php session with Jquery

0

I'm trying to quit a sessão php and redirect a user after a password change to force new login on the return of an action, the redirection is occuring but I'm not exactly sure how to end the session at that time. p>

What I have in return for password change is this:

if (response.codigo == "1") {
    $("#msgResultadoSenha").html('×AVISO!' + response.mensagem + '');

    // Atualizando os dados do formulário
    window.location.href = "index.php#ajax/iPerfil.php";

} else {
    $("#msgResultadoSenha").html('×ATENÇÃO! ' + response.mensagem + '');
}
    
asked by anonymous 09.06.2017 / 16:03

1 answer

0

Following the tip of Everson, I did the following, in php it was like this, after changing the password:

    // DESTRUINDO A SESSÃO
    session_start();
    session_unset();
    session_destroy();
    session_write_close();
    setcookie(session_name(),'',0,'/');
    session_regenerate_id(true);    

On return:

if (response.codigo == "1") {
    $("#msgResultadoSenha").html('×AVISO!' + response.mensagem + '');

    setTimeout(function(){location.href="login.php"} , 5000);   

} else {
    $("#msgResultadoSenha").html('×ATENÇÃO! ' + response.mensagem + '');
                            }
    
09.06.2017 / 18:14