Welcome Guest, Not a member yet? Register   Sign In
What is wrong with my usage of isset ?
#1

Code:
//if (isset($this->session->account_level))
      $accesslevel = $this->session->account_level;

I don't really need the if statement anyway, but if I use it the result is always false.
Reply
#2

Then $this->session->account_level doesn't exist.
Reply
#3

If I comment out the if statement like I did the variable $accesslevel is set to a value, so it must exist. Maybe it's thought of as being a property rather than a variable and perhaps isset doesn't work with properties. Just a guess.
Reply
#4

(This post was last modified: 09-14-2015, 08:36 AM by mwhitney.)

If I'm reading PHP's documentation correctly, the Session library would have to define __isset() for this to work properly. It might also be worthwhile to define __unset().

__isset() might look something like this (based on the current definition of __get()):
PHP Code:
public function __isset($key)
{
    if (isset($_SESSION[$key])) 
    {
        return isset($_SESSION[$key]);
    
    elseif ($key === 'session_id'
    {
        return session_id() !== '';
    }

    return FALSE;

Reply




Theme © iAndrew 2016 - Forum software by © MyBB