Load session_start() only if session does not exist?

前端 未结 5 1236
不知归路
不知归路 2020-12-15 22:15

is there a short code trick to check if a session has started and if not then load one? Currently I receive an error \"session already started...\" if I put in a session sta

5条回答
  •  无人及你
    2020-12-15 23:02

    Many people simply use @session_start() to suppress the warning that the session has already been started. The alternative is usually:

    if (session_status() === PHP_SESSION_NONE) session_start();
    

提交回复
热议问题