I’ve got question to you. I have got two project in PHP that uses captcha, and write it to session. My question is, if I fire first application, that saves captcha to $_SESSION['code'] and then I start second application where I saves captcha to same variable, then the first value will be overwritten by second, or PHP will create two independent sessions?
I’ve got question to you. I have got two project in PHP that uses
Share
Normally, each application will override the session variables on the same server.
To avoid this, you can either namespace your sessions or use the
session_namefunction.You can namespace manually, by setting
$_SESSION['app1']['code']and$_SESSION['app2']['code']or by using a session abstraction library like the one from Symfony or Zend Framework.Using
session_namein each application could look like this:You’ll have to change the unique id in some configuration file for each application. I put a
definehere to show that it doesn’t come out of thin air.