I’m currently integrating two php applications:
- A large bespoke PHP web app built over many years, and not written in CakePHP.
- A small CakePHP dashboarding app (jSlate).
The cake app is on the same domain and in a subfolder of the main app.
In the CakePHP app I need to access data that was set in $_SESSION by the main bespoke app, but it doesn’t appear accessible. I assume Cake is doing something with the session data. Is it storing it somewhere I can access it and if so how?
I’ve tried the answer from Accessing cakephp session variable from a php script?, namely:
session_name('CAKEPHP');
session_start();
print_r($_SESSION);
But it doesn’t contain the session variable I need.
The main app needs to specify a session_name before setting its variables:
Then in the CakePHP app, you can access this via:
The final line is important as it resets the session name back to that of the Cake App, without which the cake session variables would be inaccessible.
Alternatively you could set the main app and the cake app to use the same session name, but this introduces the possibility of naming conflicts.