Welcome Guest, Not a member yet? Register   Sign In
Session data
#1

[eluser]rijobo[/eluser]
Hello,

I've got a login form which I'm using from the book Professional Codeigniter.

This is the function in the model:

Code:
function verifyUser($u,$pw){
        $this-> db-> select('id,gebruikersnaam');
        $this-> db-> where('gebruikersnaam',$u);
        $this-> db-> where('wachtwoord', $pw);
        $this-> db-> where('status', 'actief');
        $this-> db-> limit(1);
        $Q = $this-> db-> get('leden');
        if ($Q-> num_rows() > 0){
            $row = $Q-> row_array();
            $_SESSION['gebruikersid'] = $row['id'];
            $_SESSION['gebruikersnaam'] = $row['gebruikersnaam'];
        }else{
            $this-> session-> set_flashdata('error', 'Sorry, uw gebruikersnaam of wachtwoord is niet juist!');
        }
    }
When I echo $_SESSION[ 'gebruikersid'] I see 1, so that's correct.

This controller function uses this model function:

Code:
function verify(){
        if ($this-> input-> post('gebruikersnaam')){
            $u = $this-> input-> post('gebruikersnaam');
            $pw = $this-> input-> post('wachtwoord');
            $this-> mleden-> verifyUser($u,$pw);
            if ($_SESSION['gebruikersid'] > 0){
                redirect('ledenhoek/dashboard','refresh');
            }
        }
    }

It redirects me to ledenhoek/dashboard, which is de controller function:

Code:
class Dashboard extends Controller {
    function Dashboard(){
        parent::Controller();
        session_start();
        if ($_SESSION['gebruikersid'] < 1){
            redirect('home/index','refresh');
        }
    }
    
    function index(){
        $data['title'] = "Ledenhoek Just4Fun";
        $data['main'] = 'content';
        $data['content'] = $this->mpaginas->getContent('leden_home');
        $this-> load-> vars($data);
        $this-> load-> view('dashboard');
    }
}

The problem is that this page redirects me to home/index, but I do have the $_SESSION['gebruikersid'] set.
Can anybody help me with this?


Messages In This Thread
Session data - by El Forum - 08-12-2010, 08:13 AM
Session data - by El Forum - 08-12-2010, 09:36 AM
Session data - by El Forum - 08-12-2010, 04:06 PM
Session data - by El Forum - 08-12-2010, 04:24 PM
Session data - by El Forum - 09-20-2010, 10:10 AM
Session data - by El Forum - 09-20-2010, 02:55 PM
Session data - by El Forum - 09-21-2010, 01:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB