Alex Rivera | Logout

Multiple PHP Sessions

Asked 2009-05-12T18:18:37.757
18

I am to build a PHP application for a website that already has another PHP application running on the same domain/server. My app will of course be using sessions, and I don't want my sessions to interfere with the existing app. For example if I want to use $_SESSION['username'], maybe the other app also uses $_SESSION['username'], which could be a problem. I'm not looking for an extra layer of security, I trust the application I'm sharing the host with. I just want to avoid bugs.

One way would be to do something like $_SESSION['MY_APP_NAME']['username'], but I want to know if there is an easier way.

I see on the PHP documentation that there is a function called 'session_module_name'. The name sounds good, but the docs don't really explain what it is for.

Any advice?

Edit
Report

1 Answer

33

There is an easier way: session_name.

Prior to calling session_start(); call session_name("something"); (where you change something to whatever you want it to be called).

answered 2009-05-12T18:20:29.017

Your Answer