Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get $_SESSION value in cakephp

I am setting up a user session from a core php app that is located in example.com/corephp/, now I want to redirect this user to example.com (the main site) which is in cakephp.

How can I retain the user session from the core php app to cakephp app?

I triend setting $_SESSION['user'] = someone and $_SESSION['token'] = token from core php app and tried to retrieve that value from cakephp but it didn't work.

I tried to google for this but no proper answer that could work.

Thanks in advance.

---------------------- edit

I have tried adding session_name('CAKEPHP'); to the core php app. As well as tried to reduce the security level of my cake app from medium to low.

like image 349
happyhardik Avatar asked Nov 04 '22 23:11

happyhardik


1 Answers

Didn't test, but try this.

In your corephp app:

$_SESSION['Auth']['User'] = $someone;

My reasoning is that it will set the $_SESSION, but maybe CakePHP doesn't recognize it for some reason. So we set it the right way using Cake's API:

In CakePHP

$this->Session->write('Auth.User', $_SESSION['Auth']['User']);
like image 155
stan Avatar answered Nov 09 '22 09:11

stan