I inherited the following code which is interesting. The logic seems either redundant or down right wrong.
// make the use of sessions possible.
if (!session_id()) {
session_start();
}
However, it is on a large scale subscriber system an I am reluctant to change it. Although experienced with PHP, I would appreciate the communities input to ensure I’m not missing something.
Bonus points if you can mention side-effects or insight into the current code.
UPDATE
Maybe logic wasn’t the right word. Why check session_id() before calling session_start(), when it would always return the empty string as no where else in the code is session_start() called.
This code is needed to check if session is already started. If session is started, no need to initialize it again. Furthermore, trying to call session_start() when session is already initialized will create E_NOTICE error.