Jump to content

Recommended Posts

I'm working on a facebook app, and I can't for the life of me figure this one out. 

 

I need to create a session to pass some variables between pages.  It works just fine when I run the page on my site, however when I try to view it on the facebook site, the session never carries over.  POSTing stuff works just fine.

 

At first session_start(); was all i needed, but I read that facebook had problems with carrying over sessions, so I'm using the code from here: http://wiki.developers.facebook.com/index.php/PHP_Sessions

 

require_once 'appinclude.php';
ini_set("session.save_path", "/home/ckf/phpsessions/");
//***********************************
// Create Session Using Facebook Params
//***********************************

$API_KEY = 'my key is in here';

$prefix = ($_REQUEST['fb_sig_user']) ? 'fb_sig' : $API_KEY;

if( isset($_REQUEST[$prefix.'_session_key']) ){
    session_name( $_REQUEST[$prefix.'_session_key'] );
    session_start();

    $_SESSION['fb_user']        = $_REQUEST[$prefix.'_user'];
    $_SESSION['fb_session_key'] = $_REQUEST[$prefix.'_session_key'];
    $_SESSION['fb_expires']     = $_REQUEST[$prefix.'_expires'];
    $_SESSION['fb_in_canvas']   = $_REQUEST[$prefix.'_in_canvas'];
    $_SESSION['fb_time']        = $_REQUEST[$prefix.'_time'];
    $_SESSION['fb_profile_update_time'] = $_REQUEST[$prefix.'_profile_update_time'];
    $_SESSION['fb_api_key']     = $_REQUEST[$prefix.'_api_key'];
} else {
    // Just so there *is* a session for times when there is no fb session
    session_start();
}

 

 

and I have the same in the pages where I POST information to. 

 

Any Ideas? 

 

Colin

Link to comment
https://forums.phpfreaks.com/topic/62867-facebook-php-session-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.