Welcome Guest, Not a member yet? Register   Sign In
Annoying logic problem
#1

[eluser]richzilla[/eluser]
Hi all, im having a bit of a logic issue in one of my controllers, and i am going mad trying to work out whats causing the problem, ive tried absolutely everything i can think of and it just refuses to work. Basically i have my controller:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Clients extends Controller {
    
    function __construct()
    {
        parent::Controller();
        if (($this->session->userdata('loggedIn') != TRUE) OR ($this->session->userdata('usergroup') != 5))
        {
            redirect ('login');
        }
    }

The above should be obvious, it should redirect anyone who is either not logged in, or not in the correct usergroup to the user page, however it doesnt, it always goes on to the next function, and then it throws a database error trying to retrieve results for a user that does not exist.

More annoyingly still, i have an identical set up in my 'admin' controller,with exactly the same code, just a different user group, and that works perfectly. Any help on this would be appreciated, as im really getting stuck in a hole trying to solve this, and if i have just managed to overlook something stupid ill be even more greatful.

Cheers
#2

[eluser]bigtony[/eluser]
I assume your session library is autoloaded? Probably worth just echoing out what the session vars contain before you do the if.
#3

[eluser]InsiteFX[/eluser]
Try this

Code:
if (($this->session->userdata('loggedIn') !== TRUE) OR ($this->session->userdata('usergroup') != 5))

If that does not work assign a 1 to loggedIn

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB