How do check if a PHP session is empty?

后端 未结 8 1002
無奈伤痛
無奈伤痛 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.

    0 讨论(0)
  • 2020-12-02 16:15

    you are looking for PHP’s empty() function

    0 讨论(0)
提交回复
热议问题