I am using PHP5 and CodeIgniter and I am trying to implement a single-sign on feature with facebook (although I don't think that facebook is relevant to the question). I am somewhat of a novice with PHP and definitely one with CodeIgniter, so if you think my approach is just completely off telling me that would be helpful too.
So here is in short what I am doing:
//Controller 1
$this->load->plugin("facebook");
$facebook = new Facebook(array (
'appId' => $fbconfig['appid'],
'secret' => $fbconfig['secret'],
'cookie' => true,
)
);
$fbsession = $facebook->getSession(); //works fine
$this->session->set_userdata('facebook', serialize($facebook);
Now I would like to grab that facebook object in a different controller.
//Controller 2
$facebook = unserialize($this->session->userdata('facebook'));
$fbsession = $facebook->getSession();
Produces the error: Call to undefined method getSession. So I look up more about serialization and think that maybe it just doesn't know what the facebook object's attributes are.
So I add in a
$this->load->plugin('facebook');
To controller 2 as well and I get a "Cannot redeclare class facebook." I am strongly suspecting that I am misunderstanding sessions here. Do I have to somehow tell PHP what kind of object it is? Thanks for the help.