[eluser]kevinh21[/eluser]
Hi everyone
I'm programming an administrator-backend for my website. I use the erkanaauth library to make this easier.
Now i have some problems with flashdata to show a message when the access is denied.
admin controller:
Code:
function settings()
{
if($this->erkanaauth->try_session_login())
{
$this->_showSite('admin/settings', 'left_settings');
}else{
$this->session->set_flashdata('status', 'You must be logged in to view this page');
$this->_showSite('admin/login');
}
}
...
function _showSite($module, $leftmodule = false)
{
$data['module'] = $module;
if($leftmodule <> false) $data['left'] = $leftmodule;
$this->load->view('admin_layout', $data);
}
admin/login.php (view):
Code:
<div class="content wide">
<h1 id="login">Login</h1>
<hr />
<?=$this->validation->error_string;?>
<?php echo '<p class="notice">'.$this->session->flashdata('status').'</p>';?>
<form class="login" action="<?=site_url('admin/login')?>" method="post">
.....
</form>
</div>
The Problem:
If i call admin/settings, it should check if i'm logged in. If not, it should set a flashdata message (status) and show the admin/login.php view with my function showSite().
In this view, it should display the flashmessage i set.
But he is not showing the message when i'm cliking on a link that refers to admin/settings.
I need to click at least twice, then it will show me the flashmessage.
What i'm doing wrong?