1

I've got a FB app (PHP/codeigniter).. works great.. woo. However, in IE, it refreshes and refreshes over and over. Chrome and the Fox are fine.

I'll include my connection class below, but basically, my FB app points to this, it does it's magic and the user is then passed to another controller for the rest of the session.

Anyone had experience with this before? I am on IE version 8 64 Bit on Win 7, but others have complained on other versions and OS's. I've googled about but seem(?) to be the only man with this prob.. :-(

Anyhoo, here's my controller.



/** * @property Model_user $model_user * @property Model_session $model_session */ class Blue_Connect extends Controller {

function Blue_Connect() { parent::Controller(); $this->load->plugin('facebook'); } function index() { $this->load->model('Model_user', 'model_user'); $this->load->model('Model_session', 'model_session'); $my_url = $this->config->item('facebook_url'); if ($this->session->userdata('user_id') > 0) { echo "<script>window.location.href='/buzz/';</script>"; die(); } else { if(!isset($_REQUEST["code"])) { $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $this->config->item('app_id') . "&scope=" . $this->config->item('facebook_perms') . "&redirect_uri=" . urlencode($my_url); echo "<script>top.location.href='" . $dialog_url . "'</script>"; die(); } $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $this->config->item('app_id') . "&perms=" . $this->config->item('facebook_perms') . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $this->config->item('app_secret') . "&code=" . $_REQUEST["code"]; $access_token = file_get_contents($token_url); $graph_url = "https://graph.facebook.com/me?" . $access_token; $tmp_graph = file_get_contents($graph_url); log_message("error", $tmp_graph); $user = json_decode($tmp_graph); $image = 'http://graph.facebook.com/'.$user->id.'/picture?type=large'; $user_id = $this->model_user->process_user($user->id, $user->name, $user->email, $image); $this->session->set_userdata(array('fb_id' => $user->id, 'user_id' => $user_id, 'access_token' => $access_token)); echo "<script>window.location.href='/blue_connect/';</script>"; die(); } }

}

Beertastic
  • 691
  • 1
  • 9
  • 27

1 Answers1

1

Did you set $config['uri_protocol'] = 'PATH_INFO'; in config.php? I've had this problem before, and this fixed it for me. Codeigniter doesn't allow GET parameters by default, so the session can't be set. If this doesn't help, then comment out the window.location.reload(); line if you are using the JS SDK.

DannyKK
  • 971
  • 12
  • 16
  • Thanks for the reply.. I do indeed have PATH_INFO set... I can't comment out that line as I need to redirect the iframe page. Still same issue, as nothings changed... – Beertastic Apr 07 '11 at 13:41
  • Well that's why the redirection happens, the JS SDK never actually gets the session. You can manually set the session with the PHP SDK $facebook->setSession('SESSION HERE', true). The second parameter sets the cookie, and then the JS can find it. I usually just use PHP for redirection, the JS SDK is unreliable in my experience. Today the comment boxes on all my applications don't work because of it... – DannyKK Apr 08 '11 at 14:40
  • 1
    Sry, just noticed you are using IE8, some versions of IE don't allow cookies to be set from iframe. Try putting this header at the top of your page: – DannyKK Apr 08 '11 at 14:46