I am trying learn integrating fb connect with a website. There I am facing some issue as follows.
After submitting the facebook information from (http://www.mydomain.com/exp/login.php) I am calling, process_data.php in the redirect uri like this,
<fb:registration fields="[
{'name':'name'},
{'name':'email'},
{'name':'who', 'description':'additional info', 'type':'text'}]"
redirect-uri="http://www.mydomain.com/exp/process_data.php"
</fb:registration>
Then, in the process_data.php, I do the following,
if ($_REQUEST) {
$response = parse_signed_request($_REQUEST['signed_request'],
$appSect);
if($response){
$_SESSION['facebook_data'] = $response;
header('Location: '.$redirect_url); //http://www.mydomain.com/exp/home.php
} else {
echo '$_REQUEST is empty';
}
and Finally, in the home.php,
<?php
session_start();
if(isset($_SESSION['facebook_data'])){
//do something with data
{
?>
but it never hits this code in home.php.
Is there anything to do with the hosting? or am I am doing something wrong?
Thanks in advance,
Kasun
When you're redirecting, try doing:
header("Location: newpage.php?PHPSESSID=".session_id());
And then:
session_id($_GET['PHPSESSID']);
session_start();
AFAIK the problem arises when you set a session variable and then redirect immediately, which not always works.
Note that it is better to store the session id in a cookie rather than in the URL.
Alternatively try using exit
right after the redirect:
header("Location: newpage.php");
exit;