保存来自 facebook open id 的信息

发布于 2024-11-19 14:23:02 字数 767 浏览 2 评论 0原文

我正在做一个项目,其中用户通过注册网站以及使用 Facebook 登录信息来登录。 我可以使用 facebook 登录信息登录,但我如何保存用户的信息,以便他下次登录 该网站将显示他的信息(就像在 stackoverflow 中一样)。我正在使用 PHP-smarty。

print_r($_SESSION)

     Array
(
    [fb_117743971608120_state] => 9cec0afaeea766a4c604308d750cae27
    [fb_183884308338472_code] => 085FCZlNVcOmjOb5-oejUDGSXEypJf6K5gOGCUjbFDg.eyJpdiI6Ii1nODJpOWFuZHh0bUh4VzNVc3d3OEEifQ.1DvUVqsbPFAhK9lgOYvwBH9qrpQkjYhbA9s8nVxCgnefVyGQX3KjSSCEiN1Rs0GfnGqgwYESDuPlDjEpPRGhkK5kn4U4CExgm22URCr45EM44vjL5wEFyT8WbWzPoE0_tYSkHgmEc5TPNBP1GB1z-g
    [fb_183884308338472_access_token] => 183884308338472|2.AQB3ExZ8y5FeCiR5.3600.1310461200.1-100000525094244|JxU5yIl32MnS2jWuci_p6qllPEI
    [fb_183884308338472_user_id] => 100000525094244
)

I am doing a project in which user cal log in by registering to the site as well as using facebook login information .
I am able to log in using facebbook login information but how will I save the information of the user so that next time he logs in
the site will show his information (like in stackoverflow) . I am using PHP - smarty .

print_r($_SESSION) is

     Array
(
    [fb_117743971608120_state] => 9cec0afaeea766a4c604308d750cae27
    [fb_183884308338472_code] => 085FCZlNVcOmjOb5-oejUDGSXEypJf6K5gOGCUjbFDg.eyJpdiI6Ii1nODJpOWFuZHh0bUh4VzNVc3d3OEEifQ.1DvUVqsbPFAhK9lgOYvwBH9qrpQkjYhbA9s8nVxCgnefVyGQX3KjSSCEiN1Rs0GfnGqgwYESDuPlDjEpPRGhkK5kn4U4CExgm22URCr45EM44vjL5wEFyT8WbWzPoE0_tYSkHgmEc5TPNBP1GB1z-g
    [fb_183884308338472_access_token] => 183884308338472|2.AQB3ExZ8y5FeCiR5.3600.1310461200.1-100000525094244|JxU5yIl32MnS2jWuci_p6qllPEI
    [fb_183884308338472_user_id] => 100000525094244
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光清浅 2024-11-26 14:23:03

我没有使用过 Facebook 登录,但我假设它的操作方式与任何其他登录类似。也就是说,您需要使用某种可在访问者返回时使用的持久结构。

例如:

<?php
    // Start the session (important!)
    session_start();

    // Set the session on login
    $_SESSION['login_token'] = "some_identification_info";

    // You can check to see if the login was successful, if it is
    // then the user is logged in. This will persist across pages, and
    // you can set the "time" to expire.
?>

您还可以查看cookie。请注意,上面的代码没有经过测试,我只是在凌晨 2 点输入它,所以我很有可能错过了一些东西。查看 SessionsCookie

I haven't worked with Facebook logins, but I am going to presume that it operates in a similar fashion to any other login. That is, you'll need to utilize some sort of persistent structure that can be utilized on a visitors return.

For instance:

<?php
    // Start the session (important!)
    session_start();

    // Set the session on login
    $_SESSION['login_token'] = "some_identification_info";

    // You can check to see if the login was successful, if it is
    // then the user is logged in. This will persist across pages, and
    // you can set the "time" to expire.
?>

You may also take a look at cookies. Please note that the above code was not tested, I just typed it out and its 2AM so there is a very real chance I missed something. Take a look at the documentation for Sessions and Cookies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文