I have 2 separate PHP apps running on the same domain server: abc.com/demo & abc.com/live
There is session_start() on almost every PHP page in both these apps. As soon as a single user interacts with the second app, the first app freezes or stops working. I think the same session ID is being used by both, which causes this conflict.
I read on PHP manual that specifying the PHP session name like
session_name("DEMO");
or session_name("LIVE"); may help.
My question is, do I need to specify the session_name on each and every PHP page in both the apps, or is only required when the session is first created, during the login success process.
Kindly advise. Thanks.
"On each and every ... page" is the right way.
But separate it into another script, and include that in other scripts.
Because you name your sessions "DEMO" and "LIVE", maybe place logic to decide session in a file which is shared and/or used by both apps.
$isProduction = ...;
session_name($isProduction ? "LIVE" : "DEMO");
session_start();