Welcome Guest, Not a member yet? Register   Sign In
x ||(or) y in php
#1

[eluser]Gabi3xz[/eluser]
I set session and cookies and when I go to a page to check if at least one of them is valid.
Code:
if (!$this->session->userdata('logged_in')||!$this->input->cookie('gabi_cookie')) {
           redirect('login');  
}
What is not correctly?
#2

[eluser]gRoberts[/eluser]
This is because should one be true, the other may be false, causing the if statement to return true and redirect to `login`.

I think what your looking at doing is redirecting if both don't exist, meaning you want to change from pipe (||) to ampersand (&&).




Theme © iAndrew 2016 - Forum software by © MyBB