Presumably there's some tiny performance hit, but beyond that?
views:
86answers:
5As of PHP 4.3.3, calling session_start() while the session has already been started will result in an E_NOTICE warning. The second call to session_start() will simply be ignored.You could check if the session has been started first or not with:
if (session_id() == "")
session_start();
From the docs:
As of PHP 4.3.3, calling session_start() after the session was previously started will result in an error of level E_NOTICE. Also, the second session start will simply be ignored.
So no, it won't "cause harm", but it'll throw an error. And the fact that it's happening is probably an indicator that you're doing something incorrectly, and might need to re-think how your code is laid out.
Reading the docs for session_start, all I can see is:
As of PHP 4.3.3, calling
session_start()
after the session was previously started will result in an error of levelE_NOTICE
. Also, the second session start will simply be ignored.
So, you'll get an E_NOTICE
and be ignored.
If the session is already open, then it will return an error notice, and the new session will be ignored. So no harm is done, but you will have a pesky error.
But... if you are finding the need to do this then it could be a symptom that your code is not organized well. It would probably be in your benefit to see how you can keep yourself from repeating redundant tasks like starting a session.
I usually put a session start statement in an include file that I require_once. But I don't think there should be an issue with multiple calls.