Reputation: 49451
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?
Upvotes: 18
Views: 29126
Reputation: 3948
Another thing that may help you in keeping apps separate is move the session storage to another place either setting session.save_path
in php.ini to a folder of your choice or calling session_save_path()
before session_start().
Upvotes: 2
Reputation: 88846
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).
Upvotes: 33