[eluser]Cgull[/eluser]
Hello,
I am using codeigniter 2.1.3
ionauth: benedmunds-CodeIgniter-Ion-Auth-0629c89
I have create a controller in a libraries folder:
Code:
class Admin_Controller extends MY_Controller
{
function __construct()
{
parent:: __construct();
$this->load->library('session');
$this->load->library('ion_auth');
if( !$this->ion_auth->logged_in())
redirect(site_url() . 'auth/login');
}
}
Then I created a controller called dashboard that extends the Admin_Controller:
Code:
class Dashboard extends Admin_Controller
{
public function __construct()
{
parent:: __construct();
}
public function index()
{
$this->data['subview'] = 'admin/dashboard/index';
$this->load->view('admin/_layout_main', $this->data);
}
public function modal()
{
$this->load->view('admin/_layout_modal', $this->data);
}
}
In the login view I print the session and if the user is logged in I echo 'yes':
Code:
<h3>Login</h3>
<?php echo $this->ion_auth->logged_in() ? 'yes' : 'no';
echo 'Session ' . $this->session->userdata('user_id');
?>
I have restarted my computer.
When I go to: localhost/mysite/admin/dashboard:
I go into the dashboard without loggin in.
When I click the logout link:
Code:
<?php echo anchor('auth/logout', '<i class="icon-off"></i> Logout'); ?>
I get the login screen and the variables that I echo are 'yes' and session is empty.
I don't see any errors, and the ci_sessions table is empty.
When I try to login with the right login details, the screen just goes back to the login screen.
Why am I not logged out when pressing the logout link?
And why when I login I am redirected to the login screen again?
Thank you
The solution:
After hours of breaking my head, I realised php does not really connects to the database.
I had WAMP installed on my machine and yesterday I decided to be brave and install php/apache/mysql manually following a tutorial I found online.
Everything seemed to work fine but I guess it didn't.
Installed WAMP again and everything is fine now.
That'll teach me...