PHP logic for session_id() and session_start()

Viewed 27303

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.

4 Answers
Related