[eluser]autoreverse[/eluser]
I'm building a site with a common view template which includes a Login/Logout menu option that should toggle with the visitor's logged-in status.
I'm using SimpleLogin to control access. My questions is: How can I access changed session user_data from a view
(without redirecting)?
SimpleLogin calls sess_destroy on logout which only sets a new cookie so does not affect the session data object.
I've tried placing
Code:
$this->session->set_userdata('logged_in', FALSE);
in the controller but I can't figure out how to reflect this in the view.
The relevant controller code is:
Code:
function logout() {
//Logout
$this->simplelogin->logout(); // call sess_destroy() in the CI Session class.
$this->data['page_content'] = 'account_loggedout'; // identifies the 'logged_out' view
$this->data['main_title'] = 'Logged Out'; // page title
$this->load->view('templates/container', $this->data); // load the generic template
}
The view template:
Code:
<?php if($this->session->userdata('logged_in')) { ?>
<a href="/user/logout">Logout</a>
<?php } else { ?>
<a href="/user/">Client Login</a>
<?php } ?>
Any help would be appreciated.