我有一个经典的用户身份验证,其中包含带有电子邮件+密码的表单。如果auth是正确的,我会$_SESSION['auth']=true
。
我使用此会话变量在每个页面上显示“登录”内容,如下所示(示意图)。
if($_SESSION['auth']==true)
{
echo $loggedcontent;
}
else
{
echo $notloggedcontent;
}
现在我也有一个Facebook登录。我使用Javascript SDK,它的工作原理。 问题是,如果facebook日志正确,我需要将$ _SESSION ['auth']设置为true,但由于整个facebook日志过程都是浏览器端,我看不到我能做什么。
现在,我使用ajax调用来设置会话变量:
FB.login(function(response)
{
if (response.authResponse)
{
FB.api('/me', function(response)
{
//Here I make an ajax call that set $_SESSION['auth'] to true and then reload the page to display logged in content
});
}
},{scope: 'email'});
我的问题是有人可以直接调用我的ajax,忽略facebook进程。何时以及如何在我的服务器上设置登录信息?