2011-11-21 41 views
2

我正在使用codeigniter,我只是想知道我如何才能從會話中斷開連接,並從Facebook ni中單擊一個鏈接?如何在單個HTML鏈接中進行雙重重定向?

讓我解釋一下,我存儲在某些$數據中的一些FB信息 我也有一個會話爲用戶設置

當我按下注銷按鈕 用戶/註銷()「> DeconnexionFB

我撥打的用戶控制器內的註銷功能 下面是函數:

public function logout() 
{ 
    $this->session->sess_destroy(); 
    $fb_data=NULL; 

    redirect('site','refresh'); 
} 

但whar我想的DOI在同一時間斷開日從FB到達註銷網址e用戶加入他的FB會話,因爲我需要一個外部URL的錨點。 刪除$ fb_data並破壞我的會話後,我怎麼能自動將我的網站重定向到控制器中的地址?

錨那樣: 斷開

感謝您的回答:)

+0

請詳細解釋 – Sedz

回答

1

我願意爲Facebook添加JavaScript的SDK到您的網站,如果你已經沒有,加入:

<div id="fb-root"></div> 
<script> 
window.fbAsyncInit = function() { 
    FB.init({ 
    appId  : 'YOUR_APP_ID', // App ID 
    channelURL : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File 
    status  : true, // check login status 
    cookie  : true, // enable cookies to allow the server to access the session 
    oauth  : true, // enable OAuth 2.0 
    xfbml  : true // parse XFBML 
    }); 
    // Additional initialization code here 
}; 
// Load the SDK Asynchronously 
(function(d){ 
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    d.getElementsByTagName('head')[0].appendChild(js); 
}(document)); 
</script> 

http://developers.facebook.com/docs/reference/javascript/

複製然後在你的代碼,你會打電話:

FB.logout(function(response) { 
    // user is now logged out 
}); 

http://developers.facebook.com/docs/reference/javascript/FB.logout/

複製有了這個,你不會有重定向到另一個頁面,但把它在你的註銷頁面。但要注意,有些人在註銷網站的同時不希望從Facebook註銷。