TL DR : change the configuration parameter of CherryPy tools.sessions.name to something unique for each application.
Long answer :
I know this is a very old question, but I think there is a very simple answer. Writing below for future search engines.
CherryPy uses cookies to search for sessions. By default, this is called session_id and has a random hexadecimal string as the value. If CherryPy receives a session_id that it does not recognize, it will generate a new session_id. This is a measure to prevent session fixation.
If you have two applications in the same domain. They both use the same cookie name (ie, "Session_id"), but do not recognize the session_id of the other and therefore overwrite it with a new one. Therefore, switching from one application to another cancels the session.
The solution is simple: in the CherryPy configuration, you can redefine the session_id name by setting tools.sessions.name to something other than "session_id", for example, "myapp_session_id" and "myotherapp_session_id".
You need to make sure that the session store is separate, as you correctly defined.
In the above example, you would do something like this:
site1conf = { 'global': { 'server.socket_host': HTTP_HOST, 'server.socket_port': HTTP_PORT, 'tools.sessions.on': True, 'tools.sessions.storage_type': 'file', 'tools.sessions.storage_path': '/tmp/site1_sessions/', 'tools.sessions.name': 'site1_session_id', 'tools.sessions.timeout': 1440 } } site2conf = { 'global': { 'server.socket_host': HTTP_HOST, 'server.socket_port': HTTP_PORT + 10, 'tools.sessions.on': True, 'tools.sessions.storage_type': 'file', 'tools.sessions.storage_path': '/tmp/site2_sessions/', 'tools.sessions.name': 'site2_session_id', 'tools.sessions.timeout': 1440 } }
Note. In my own applications using CherryPy 10.0.0, I used this configuration parameter at the application level and at the path level. I have not tested this with older versions of CherryPy, but looking at the source code, it seems like this has been possible for more than a decade.
Since writing this document, I have implemented an update to CherryPy's documentation about this, included here: http://docs.cherrypy.org/en/latest/pkg/cherrypy.lib.html#session-fixation-protection