We may replace a PHP app with a Java EE app, but the problem is we wanna replace the modules one by one, which means two apps would co-exist and communicate with each other.
So is it possible to share the user session between the 2 apps? Or use a cookie to solve the problem?
Save your session data to a database with session_set_save_handler().
UPDATE
Efficiency wise it would be very mininal, the difference from reading a text file to querying a database (presumably using an existing connection).
Some example code (simplified from what I use)
The you can read/write to the session data using
$_SESSION['name'] = data;in the usual technique.