CodeIgniter Forums
Reading Session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Reading Session (/showthread.php?tid=64130)



Reading Session - donpwinston - 01-18-2016

$this->session->userdata('item') returns the item or NULL which is what I want. But the docs say this method exists for backward compatibility. The preferred way is to use:

$this->session->item

It appears that this also returns NULL if the item does not exist. Before I tried it I assumed it would error out with an unknown property error because item is not a function. What's going on?


RE: Reading Session - Narf - 01-18-2016

https://secure.php.net/manual/en/language.oop5.overloading.php#object.get