Saving information from facebook open id

南楼画角 提交于 2019-12-12 01:37:43

问题


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
)

回答1:


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.



来源:https://stackoverflow.com/questions/6660657/saving-information-from-facebook-open-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!