Welcome Guest, Not a member yet? Register   Sign In
How to check session variable is empty ?
#14

[eluser]CroNiX[/eluser]
Code:
$logindata = $this->session->userdata('username');

if ($logindata !== FALSE)
{
  //it exists
}
Same with CI's input methods and just about everything else (returns boolean FALSE if it doesn't exist). Although they will probably be changing it to NULL in CI3 instead of false.

This is really super easy to figure out if you just look at their code in addition to the docs:

From session.php:
Code:
function userdata($item)
{
  return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
}


Messages In This Thread
How to check session variable is empty ? - by El Forum - 09-29-2009, 01:09 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 01:40 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 01:57 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 01:59 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 02:46 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 02:52 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 02:59 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 03:12 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 03:15 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 03:28 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 03:32 AM
How to check session variable is empty ? - by El Forum - 09-29-2009, 03:41 AM
How to check session variable is empty ? - by El Forum - 05-03-2012, 08:16 AM
How to check session variable is empty ? - by El Forum - 05-03-2012, 10:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB