[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?