isLoggedIn Problem

In my site i am using a simple templating system, where i load one view file and pass a variable to the view that contains what view file to load.

When a user is logged in the sidebar changes to accomidate the logged in user with a profiel and logout link.

But if you go to any other page the side bar seems to think the user isnt logged in even though they are.

The template file loads header.php and footer.php files. the header file contains the sidebar and the the code that check when the user is logged in.

here is all of header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
&lt;html &gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;&lt;?php if(!isset($title)){ echo 'Untitled Document';}else{echo $title;} ?&gt;&lt;/title&gt;
&lt;link rel="stylesheet" href="http://localhost:8888/ci/css/&lt;?php if(!isset($css)){ echo 'styles.css';}else{echo $css . '.css';;} ?&gt;" type="text/css" media="screen" /&gt;


<div class="wrapper">
        <div class="header">
            <img src="http://localhost:8888/ci/img/logo.png" alt="Theatre311" />
            <span><img src="http://localhost:8888/ci/img/ad.png" /></span>
        <div class="sidebar">
            <hr />
            <li>&lt;?=anchor('http://localhost:8888/ci', 'Home')?&gt;</li>
            <li>&lt;?=anchor('theater/prices', 'Prices')?&gt;</li>
            <li>&lt;?=anchor('theater/show', 'View Shows')?&gt;</li>
            <li>&lt;?=anchor('theater/about', 'About Us')?&gt;</li>
            <li>&lt;?=anchor('theater/contact', 'Contact Us')?&gt;</li>
                if (isset($isLoggedIn))
                    echo '<li>' . anchor('members/profile', 'Profile') . '</li>';
                    echo '<li>' . anchor('members/logout', 'Logout') . '</li>';
                    echo anchor('members', 'Staff Login');
            <li><a href="mailto:[email protected]">Report a Bug</a></li>

        <div class="content">

and here is the template file you you dont quite understand
&lt;?php $this->load->view('includes/header.php'); ?&gt;

&lt;?php $this->load->view($content); ?&gt;

&lt;?php $this->load->view('includes/footer.php'); ?&gt;

How are you loading the $isLoggedIn variable? Presumably it's being stored in the session, so you could just check that in your view:
&lt;?php if ($this->session->userdata('isLoggedIn')); ?&gt;
    <li>&lt;?php echo anchor('members/profile', 'Profile'); ?&gt;</li>
    <li>&lt;?php echo anchor('members/logout', 'Logout'); ?&gt;</li>
&lt;?php endif; ?&gt;

yes it is stored in a session. I will try that when i get home. Thanks man

yup it work

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.