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?
In raidenace's answer two sessions are created for all clients shared among all visitor of the website. With this answer two sessions are created for each visitor to the website.
1000+ sessions can still be perfectly handled by standard PHP file based sessions. If you notice that is getting a problem, you can exchange the session backend easily. There are pluggable session handlers for memcached or other memory or database based storage systems.
The answer is "no". You cannot start multiple sessions simultaneously. And if you do, you'll get an error like "A session had already been started". You don't need to start simultaneous sessions, so long you can create multiple keys.
From the Start screen, open MultiPoint Manager. Click the Home tab. In the Computer column, click the name of the MultiPoint Server computer, and then, in the right pane, click Edit server settings. Select the Allow one account to have multiple sessions check box, and then click OK.
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).
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().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With