php not redirecting
        Posted  
        
            by 
                NSchulze
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by NSchulze
        
        
        
        Published on 2012-04-12T23:19:58Z
        Indexed on 
            2012/04/12
            23:29 UTC
        
        
        Read the original article
        Hit count: 321
        
I'm trying to write the logout of a website. When I do this I want the page to redirect to the login page. I think I'm doing it the correct way, but can't get the right result. Could you guys point me in the right direction?
Relevant Code:
<button onclick="logout()">Logout</button>
function logout()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.location=xmlhttp.responseText;
}
}
xmlhttp.open("GET","logout.php",true);
xmlhttp.send();
}
<?php
session_destroy();
header("Location:http://localhost:8888/loginns.html");
mysql_close($con);
?>
Thanks!
© Stack Overflow or respective owner