In my site, header contains logout section for twitter. Three files are used in these logout functionality. When the user click logout, it opens the twitter logout URL and the parent window refreshe and goes to index page in chrome.
But the parent window does not refresh in firefox. Even after the session destroy, it shows logout and if we refresh the page manual it shows sign in. Anybody can help me to solve this problem
Header.php
<li><a href="javascript:;" onclick="opennewwindow(); clearsession();">Logout</a></li>
function opennewwindow()
{
var mywin=window.open('twitlogout.php','chindhu','width=550,height=350');
}
function clearsession()
{
var req = GetXmlHttpObject();
req.onreadystatechange = function() {
if(req.readyState == 1) {
document.getElementById('status').innerHTML='<img src="images/ajax-loader.gif"/>';
}
if (req.readyState == 4 ) {
if( req.status == 200) {
document.getElementById('status').innerHTML=req.responseText;
}
else
{
alert("There was a problem while using XMLHTTP:
" + req.statusText);
}
}
}
req.open("GET", "clearsession.php", true);
req.send(null);
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
twitlogout.php
<?php
include("header.php");
header("Location:https://twitter.com/#!/logout");
?>
clearsession.php
<?php include("config/dbconfig.php");?>
<meta http-equiv="refresh" content="2;url=<?php echo URLPATH;?>">
<?php
session_start();
unset($_SESSION['id']);
unset($_SESSION['username']);
unset($_SESSION['oauth_provider']);
session_destroy();
?>