Welcome Guest, Not a member yet? Register   Sign In
Session checking & loading a new view depending on the result

Hello All,

I am new to CI and now working with Session Management. I have to check the save the data in the Session and load a new view after successful login. Yesterday I completed the login checking & session storing tasks.

After login, the left menu which shows the 'Login Box' need to be replaced with a Welcome Message and a logout link. So how can I accomplish this?

How can I call a same function which displays this Welcome Message from within all classes ?

I am waiting here to hear from you all..

Thank You,
Php Developer.

[eluser]Thorpe Obazee[/eluser]
I don't know if I understand your question but if you want the 'sidebar' to be replaced, you can load another view there like this.

<div id="sidebar">
You are logged in
<a href="#">logout</a>
&lt;?php $this->load->view('sidebar');?&gt;
<div id="content">
Welcome to the Dashboard

Thank your for your reply..

[eluser]Thorpe Obazee[/eluser]
do you want to check if the session is present then shows the 'welcome' message if the session is present but show a login form if not?

I usually do a conditional statement like this:

// check the session
if ($this->pinoytech_auth->check()) {
// if session is present, then go to dashboard.

You could do something like this in your controller.

if($this->session->userdata('login') == TRUE) {
    $data['sidebar'] = $this->load->view('welcome', '', TRUE);
} else {
    $data['sidebar'] = $this->load->view('login', '', TRUE);
$this->load->view('page', $data);
Then just echo $sidebar in your view where you want your login form OR welcome message.

Thank you for your replies...

Theme © iAndrew 2016 - Forum software by © MyBB