2012-12-22 121 views
4

我爲我的網站使用Google OpenId API。 我需要使用Google OpenId API實施Force Logout概念。在Google OpenId中實施強制註銷

下面的代碼我已經嘗試過了,但我無法獲得用於使用openId強制註銷的實際解決方案。

如何註銷Google OpenId中的當前登錄會話?

<?php 

session_start(); 
if (isset($_SESSION['id'])) 
{ 
    // Redirection to login page. 
    header("location: home.php"); 
} 

if (array_key_exists("login", $_GET)) { 
    $oauth_provider = $_GET['oauth_provider']; 
    if ($oauth_provider == 'google') { 

    $url='https://www.google.com/accounts/Logout'; 

    //After clearing a session it is redirected to login-google.php 

    $redirectUrl="login-google.php"; 

    $redirectUrl = '&return='.$redirectUrl; 

    $finalUrl = $url . $redirectUrl; 

    echo("<script>top.location.href='".$finalUrl."'</script>"); 

    } 
} 
?> 

回答