Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I losing my session on page changes?
    text
    copied!<p>So I'm trying to integrate the PHP facebook SDK/API with codeigniter, because I love codeigniter, but for some reason I keep losing my facebook session as soon as I change pages from my base URL, I have printed the $_session and all i get is Array ( [fb_339393762762289_state] => cb8c201ed66ebcaa60407114aa92f001 ) any ideas why this is happening? </p> <p><strong>Here is what my controller looks like:</strong></p> <pre><code>class Main extends CI_Controller { var $user; var $log_in_url; var $log_out_url; function __construct() { parent::__construct(); $this-&gt;load-&gt;library('facebook'); $perams = array( 'scope' =&gt; 'user_about_me, read_friendlists', 'redirect_uri' =&gt; 'http://www.example.com/' ); $this-&gt;user = $this-&gt;facebook-&gt;getUser(); $this-&gt;log_out_url = $this-&gt;facebook-&gt;getLogoutUrl(); $this-&gt;log_in_url = $this-&gt;facebook-&gt;getLoginUrl($perams); print_r($this-&gt;user); print_r($this-&gt;log_out_url); print_r($this-&gt;log_in_url); } public function index() { if ($this-&gt;user) { try { $data['user_profile'] = $this-&gt;facebook-&gt;api('/me'); } catch (FacebookApiException $e) { error_log($e); $this-&gt;user = null; } } if ($this-&gt;user) { $data['logout_url'] = $this-&gt;log_out_url; } else { $data['login_url'] = $this-&gt;log_in_url; } $data['user'] = $this-&gt;user; $this-&gt;load-&gt;view('templet/header', $data); $this-&gt;load-&gt;view('main view'); $this-&gt;load-&gt;view('templet/footer'); } public function account() { if ($this-&gt;user) { try { $data['user_profile'] = $this-&gt;facebook-&gt;api('/me'); } catch (FacebookApiException $e) { error_log($e); $this-&gt;user = null; } } if ($this-&gt;user) { $data['logout_url'] = $this-&gt;log_out_url; } else { $data['login_url'] = $this-&gt;log_in_url; } $data['user'] = $this-&gt;user; $this-&gt;load-&gt;view('templet/header', $data); $this-&gt;load-&gt;view('account'); $this-&gt;load-&gt;view('templet/footer'); } </code></pre> <p>from what I can understand from the source code of the api is that it is in charge of handling sessions, so I don't understand why it keeps losing it. </p> <p>I was thinking it could maybe have something to do with my Htaccess set up.. Ie. my url when i change pages looks like this www.example.com/index.php/controller_name/method_name/</p> <p>also do i need to do anything with the $_GET vars? because that is one thing i noticed.. there seem to be some things passed in the URL, but they don't continue on to other pages. </p> <p>any help on this would be greatly appreciated. I am really at a loss. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload