[eluser]Unknown[/eluser]
Hello,
I can't get SimpleLoginSecure to work properly. User doesn't stay logged in more than one server request. I'm only trying to hide admin dashboard from reqular users with no luck.
When I log I see message I'm logged in and a link to my dashboard. When I try to click the link I get new session id and log out automatically which isn't what I wanted. Any help with this?
Session library is loaded automatically and I'm not using database to store sessions.
auth.php controller. Echos are only there for testing purposes.
Code:
<?php
if (! defined('BASEPATH')) exit('No direct script access');
class Auth extends Controller {
//php 5 constructor
function __construct() {
parent::Controller();
$this->load->library('SimpleLoginSecure');
}
function index() {
if ($this->session->userdata('logged_in')) {
redirect('/dashboard');
} else {
redirect('/auth/login');
}
}
function login() {
$this->_validate_login();
if ($this->session->userdata('logged_in')) {
echo '<a href="/dashboard">Dashboard!</a>';
} else {
$this->load->view('auth/login');
}
}
function _validate_login() {
$u = $this->input->post('user');
$pw = $this->input->post('pass');
if($this->simpleloginsecure->login($u, $pw)) {
if ($this->session->userdata('logged_in')) {
echo 'Logged in.<br>';
}
} else {
redirect('/auth');
}
}
function logout() {
$this->simpleloginsecure->logout();
}
/*
function create_user() {
}
}
*/
}
I tried ErkanaAuth 2.0a and it seems to has same problem with session. Isn't Codeigniter 1.7.2's session library compatible with PHP Version 5.2.13?
RESOLVED: The problem was pretty simple after all. I had wrong url at $config['cookie_domain'] setting. Works now!