好的,我编写了一个代码,将用户连接到我的数据库,然后我设置为该用户的登录名,如果电子邮件已经在数据库中,我只需登录用户...
问题是注销按钮不起作用..我试过了。
session_start();
session_destroy();
在注销时,但一旦被重定向到索引页面,(我认为再次登录)
我怎样才能避免这种情况..
编辑:我不希望用户从 facebook 注销。刚从我的网站登出
这是我的代码。
<?php
if ($userId) {
//
// already logged? show some data
$userInfo = $facebook->api('/' + $userId);
if (isset($userInfo['email']))
{ include "facebookregister.php"; } else { echo "no hay permisos de facebook"; }
} else {
//
// use javaascript api to open dialogue and perform
// the facebook connect process by inserting the fb:login-button
?>
<div id="fb-root"></div>
<fb:login-button scope='email,user_birthday'></fb:login-button>
<?php
}
?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?=YOUR_APP_ID?>,
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function(response) {
// ------------------------------------------------------
// This is the callback if everything is ok
window.location.reload();
});
};
(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>
和注销。
function logout_action()
{
$srv_nms=BASE;
$srv_nms=str_replace("http://","",$srv_nms);
$srv_nms=str_replace("https://","",$srv_nms);
$srv_nms=str_replace("www.","",$srv_nms);
$srv_pats=$srv_nms;
$srv_nms_arr=explode("/",$srv_nms);
$srv_nms=$srv_nms_arr[0];
$srv_pats=str_replace($srv_nms."/","",$srv_pats);
setcookie(COOKIE_LOGINID,"",0,"/".$srv_pats,$srv_nms);
setcookie(COOKIE_USERNAME,"",0,"/".$srv_pats,$srv_nms);
setcookie(COOKIE_PASSWORD,"",0,"/".$srv_pats,$srv_nms);
session_start();
session_destroy();
header("Location: ".$this->make_url("user/login/l"));
die;
}