Cakephp loses SESSION after a redirect

Asked

Viewed 365 times

3

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

The problem is that the data of this SESSION is lost when I try to recover them on the other link.

I created a test method where it simply records a Session and in another controller I recover this SESSION in an expected way.

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

In all locations of my application I am using the $components = array('Session').

How to solve this problem?

1 answer

1

How nice it is to explain your question. I just got an idea as soon as I asked the question. Facebook SDK tries to create a session_id. Since in Cakephp’s structure it is probably called first, it ended up overwriting Cakephp’s SESSION.

I found 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 include.

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

CakeSession::read();

require_once "base_facebook.php";

Problem solved.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.