bryanjhv/slim-session

Session properties always return true if the properties is empty

ebauger opened this issue · 2 comments

Hi,

I use this stack for my Slim v4 API:

composer.json I use:

{
    "require": {
        "php": "^7.3",
        "slim/slim": "^4.3",
        "slim/psr7": "^0.6.0",
        "bryanjhv/slim-session": "^4.0"
      }
}

In my route function

// [...]
$session = new SesssionHelper();
$session->my_key = ''; // empty string
isset($session->my_key) // return true // expected true
empty($session->my_key) // return true // expected false
// [...]

Someone can replicate and validate this result?

Please explain why you expect empty() to return false when given an empty string.
https://www.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues

Please explain why you expect empty() to return false when given an empty string.
https://www.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues

Oups my mistake. Thank for your answer. expected is true not false.