CakePHP loses SESSION after a redirect

Question:

I'm doing an integration with Facebook Login. When the user clicks to login using Facebook and accepts the application he is redirected to a method that creates a SESSION and redirects.

The problem is that this SESSION's data gets lost when I try to retrieve it from the other link.

I created a test method where it simply records a session and in another controller I retrieve this SESSION as expected.

For this reason I started to suspect that the problem might be in the type of data that comes with the URL that Facebook redirects to my application.

Everywhere in my application I'm using $components = array('Session') .

How to solve this problem?

Answer:

How good is it to explain your question. I ended up getting an idea as soon as I asked the question. The Facebook SDK tries to create a session_id. As in the CakePHP framework it's probably called first, it ended up overwriting CakePHP's SESSION.

I ended up finding this solution https://groups.google.com/d/msg/cake-php/2taXmyei4LM/-x0lrx2hi20J

In the Facebook SDK file I simply placed a call to use CakePHP's SESSION features before the include.

In the Facebook PHP SDK, but precisely in the facebook.php file I included the CakeSession::read() call before the require_once:

CakeSession::read();

require_once "base_facebook.php";

Problem solved.

Scroll to Top