In PHP, is there any harm in running session_start() multiple times?

前端 未结 7 865
臣服心动
臣服心动 2020-12-03 13:37

Presumably there\'s some tiny performance hit, but beyond that?

7条回答
  •  臣服心动
    2020-12-03 13:44

    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.

提交回复
热议问题