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

[eluser]Joseph1982[/eluser]
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.
#2

[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.

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

[eluser]Joseph1982[/eluser]
Thank your for your reply..
#4

[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:

Code:
// check the session
if ($this->pinoytech_auth->check()) {
// if session is present, then go to dashboard.
    redirect('front/index');
}
#5

[eluser]Bramme[/eluser]
You could do something like this in your controller.

Code:
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.
#6

[eluser]Joseph1982[/eluser]
Thank you for your replies...




Theme © iAndrew 2016 - Forum software by © MyBB