简体   繁体   中英

How to implement Sessions in a Facebook Multi-pages canvas application (php sdk 4.0)

Here is my question: Im trying to create a Facebook Canvas Application with PHP sdk 4.0 and im lost in all the confusing documentations... I don't understand how the login process is working with multiple pages application. Can someone help me please?

I put this code on the landing page of the app and that works fine:

FacebookSession::setDefaultApplication( 'app_id', 'app_secret' );
$helper = new FacebookCanvasLoginHelper();
try {
    $session = $helper->getSession();
} catch (FacebookRequestException $ex) {}

the question is: what should i do on the second page? _Write the same code? _Save the Facebook session in $_SESSION in order to use it on the other pages? _Save only the token to retreive the session?

I walked the web for 2 days to find the answer with no result.. I found Facebook documentation is not very clear

Thx to you a lot! ;)

You need to set the session / access_token and save it to a PHP Session, eg

$_SESSION['access_token'] = $session->getToken();

This tutorial I wrote will help you out .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM