Welcome Guest, Not a member yet? Register   Sign In
Session FALSE if not exists - how do i check this?
#4

[eluser]Bart v B[/eluser]
[quote author="nevsie" date="1270605501"]Hi Noctrum,
That is kind of my point... I am using the session library, and if the item does not exist it throws up the error as mentioned above:

Code:
// Monkey does not exist in session!!!
if ($this->session->userdata['monkey'] !== FALSE) { echo "false is stated"; } else { echo "true is stated"; }

And the error:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: monkey

I know this gives the correct answer and with error reporting off this will be suppressed - but still not ideal...[/quote]

Offcourse it gives an undefined index.
It must be something like this:

Code:
// Monkey does not exist in session!!! mind the () instead of: []
if ($this->session->userdata('monkey') === FALSE)
{
  echo "false is stated";
}
else // its true so..
   {
    echo "true is stated";
   }


Messages In This Thread
Session FALSE if not exists - how do i check this? - by El Forum - 04-06-2010, 02:23 PM
Session FALSE if not exists - how do i check this? - by El Forum - 04-06-2010, 02:53 PM
Session FALSE if not exists - how do i check this? - by El Forum - 04-06-2010, 02:58 PM
Session FALSE if not exists - how do i check this? - by El Forum - 04-06-2010, 03:08 PM
Session FALSE if not exists - how do i check this? - by El Forum - 04-06-2010, 03:12 PM
Session FALSE if not exists - how do i check this? - by El Forum - 04-06-2010, 03:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB