![]() |
How to check session variable is empty ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to check session variable is empty ? (/showthread.php?tid=23060) Pages:
1
2
|
How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]suba[/eluser] pls help to me How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]Azraf[/eluser] I am also a newbie, therefore, I can help you very little. But first, you need to clarify your requirement more detail. How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]bigtony[/eluser] Code: if (empty($this->session->userdata('my_variable')): How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]affix[/eluser] bigtony's Method is correct However I usually do Code: if(isset($this->session->userdata('my_var')) Both methods are correct it just depends on 1. Your personal Oppinion 2. What you will be doing How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]bigtony[/eluser] affix: You might want to do your own checking on this, but I think you may run into a problem with: Code: if(isset($this->session->userdata('my_var')) How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]suba[/eluser] hi, if(empty($this->session->userdata('username'))){ redirect(base_url()); } but i have received Error. Fatal error: Can't use method return value in write context How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]suba[/eluser] hi, if(empty($this->session->userdata(‘username’))){ redirect(base_url()); } but i have received Error. Fatal error: Can’t use method return value in write context How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]bigtony[/eluser] Sorry, need slight adjustment... Code: $my_variable = $this->session->userdata('my_variable'); How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]wiredesignz[/eluser] [quote author="bigtony" date="1254231997"]affix: You might want to do your own checking on this, but I think you may run into a problem with: Code: if(isset($this->session->userdata('my_var')) You are both incorrect because you cannot run the isset() function on a function no matter what. How to check session variable is empty ? - El Forum - 09-29-2009 [eluser]Azraf[/eluser] good reply from all ![]() |