1
<script language='Javascript'>
function confirmacaoSair() {
var resposta = confirm('".$_SESSION['nome'].", tem que certeza que quer sair?');
if (resposta == true) {
unset({$_SESSION['nome']});
unset({$_SESSION['matricula']});
{session_destroy()};
window.location.href = 'index.php';
}
}
</script>
This way it’s not working, but my question is whether it works what I’m wanting to do.
Possible duplicate: http://answall.com/q/25136/129
– Sergio
Javascript runs in the browser while PHP code runs on the server. What you can try to do is create Javascript code while the page is being created by PHP. I’ve done this in Java (JSF). You should do it in PHP as well. See in my reply an example I copied from the OS in English. cc @Sergio
– Caffé