I have two web applications in the same domain (CMS and e-commerce platform), and I would like to share session data between them. I can easily set it up so that both of them use the same session, but there are too many possibilities for collisions of variable names in the $ _SESSION variable. I thought I could use the named sessions, but I could not get it to work:
session_name("WEB_APP_ONE");
session_start();
$webAppOneData = $_SESSION;
session_write_close();
//var_dump($_SESSION) = all of the session data for web app one is still contained in $_SESSION even though I closed the session with session_write_close()
session_name("WEB_APP_TWO");
session_start();
$_SESSION['WEB_APP_ONE'] = $webAppOneData;
//var_dump($_SESSION) = all of the session data for web app one is still here
I'm not sure if this is possible, but I would like to know if this is so!
Note: the actual use case I get shows how many products are in the visitors basket in the CMS. The cart data is stored in an e-commerce platform session, but I need to show from the CMS header. I want to have free integration between the CMS and the shopping cart.