How do I check if the user is really loggedin? $facebook->getUser()
still returns an ID after logout. Do I need to do something like $facebook->api('/me')
just to check if the user is "really" logged in?
$ facebook-> getUser()在注销后返回用户ID
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- duan3601 2011-12-24 22:11关注
Well, FB PHP SDK in my opinion is quite tricky because it relies on a cookie sent from Facebook when you are logging into the Facebook. This cookie is not deleted whilst logging out. Because of that in below code the variable $uid could store a proper user facebook id:
$uid = $facebook->getUser();
So, as far as I know, call
$facebook->api('/me');
will tell the truth whether the user is logged in or not.try { $facebook->api('/me'); /* user is really logged into FB */ } catch (Exception $e) { /* user is not currently logged into the FB */ }
I use above code in my production application and it works well.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
- ¥15 神经网络怎么把隐含层变量融合到损失函数中?
- ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
- ¥15 lingo18勾选global solver求解使用的算法
- ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
- ¥20 测距传感器数据手册i2c
- ¥15 RPA正常跑,cmd输入cookies跑不出来
- ¥15 求帮我调试一下freefem代码
- ¥15 matlab代码解决,怎么运行
- ¥15 R语言Rstudio突然无法启动