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

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

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

7条回答
  •  旧巷少年郎
    2020-12-03 13:50

    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.

提交回复
热议问题