doulaozhi6835 2014-03-23 03:47
浏览 58

从Facebook连接登录获取自定义变量?

As well as a normal user/pass login, I have a Facebook connect button on my site.

With user/pass, I've set up a "Remember me" check box. If checked, I create a token and save it as a cookie, and into the DB, so it can be used for auto logins after a php session expires.

My Facebook login is the same as the other - once FB authenticates, I log them into their account on my site by matching their FB id to the one in my database.

I'd also like Facebook sign ins to be able to use the Remember me checkbox ie if checked, and a successful Facebook auth occurs,I create a token and save it as a cookie and into my DB, ready for auto logins just like with the user/pass set up.

However, I need to somehow tell my server - "hey, this successful FB login also had the Remember me checkbox selected, so create the token and cookie".

I'm currently doing it using javascript abnd jQuery, where when the FB button is clicked, the JS stops the Facebook login, uses jquery to hit up a php script which just sets a session var 'rememberMe' to 1, then JS returns back to fire off the Facebook login link, and on a successful FB auth, I look for the 'rememberMe' session var when logging them into my system.

Problem is, sometimes the jQuery doesn't work, even though the process is exactly the same.

I'm wondering if there's a way, when logging on with Facebook, to send vars like a checkbox slection, and get that back with the auth URL string?

Or, should I just assume that anyone logging in with Facebook wants to be rememebered, and set up the cookie and token?

Thanks for your time and help.

  • 写回答

1条回答 默认 最新

  • dt4233 2014-03-23 03:51
    关注

    All you have to do is include a querystring with the keys/values you want back when telling Facebook what URL to redirect back to. After that redirection, you can read in the variables you need.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题