How do check if a PHP session is empty?

后端 未结 8 1124
無奈伤痛
無奈伤痛 2020-12-02 15:50

Is this bad practice?

if ($_SESSION[\'something\'] == \'\')
{
    echo \'the session is empty\';
}

Is there a way to check if its empty or

8条回答
  •  执念已碎
    2020-12-02 16:11

    The best practice is to check if the array key exists using the built-in array_key_exists function.

提交回复
热议问题