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

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

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

7条回答
  •  情歌与酒
    2020-12-03 13:50

    As 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();
    

提交回复
热议问题