[Solved] Adding OR / || to if statement - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [Solved] Adding OR / || to if statement (/showthread.php?tid=67448) |
[Solved] Adding OR / || to if statement - wolfgang1983 - 02-23-2017 I want to be able to do two checks on my MY_Controller.php Can check if my session token is set like PHP Code: if (!in_array($route, $ignore) && !$this->session->userdata('token')) { That works fine but want to add another another check for user_id it throws The page isn’t redirecting properly error PHP Code: if (!in_array($route, $ignore) && !$this->session->userdata('token') || !$this->session->userdata('user_id')) { How can I have both session userdata in there? PHP Code: <?php RE: Adding OR / || to if statement - neuron - 02-23-2017 Hi, I did not understand what you meant by "but throws redirect error", can you try in following way: if (!in_array($route, $ignore) && (!$this->session->userdata('token') || !$this->session->userdata('user_id'))) RE: Adding OR / || to if statement - wolfgang1983 - 02-23-2017 (02-23-2017, 10:13 PM)neuron Wrote: Hi, Meaning The page isn’t redirecting properly fire fox error only when I added the || or part RE: Adding OR / || to if statement - wolfgang1983 - 02-23-2017 (02-23-2017, 10:13 PM)neuron Wrote: Hi, All working now thanks |