一个简单快速的问题,我的意图是$ user在isset $ user之前运行,我正在做什么风险?它会导致任何错误。到目前为止没有问题。
我的代码
session start();
$user = $facebook->getUser();
if($user){ // i want it to run this script 1st
try{
$user_profile = $facebook->api('/me');
$_SESSION['User'] = $user_profile;
}catch(FacebookApiException $f){
echo '<pre>'.htmlspecialchars(print_r($f, true)).'</pre>';
$user = null;
}
}
$loginUrl = $facebook->getLoginUrl(array(
'scope'=> 'email,user_education_history',
'display'=>'popup',
));
if(isset($user)){ //this come up after
echo "<script>
window.close();
window.opener.location.href = 'index.php';
</script>";
}
MYWAY: 我在同一个脚本加载并关闭窗口,关闭窗口,如果设置$ user(isset)但风险太大???它会引起任何问题吗?
有人说: 有些人只是为了关闭窗口而重定向到其他空页面,只有window.close();在里面,它看起来更安全,但似乎没有任何理由加载其他页面。
哪一个更安全???