isLoggedIn Problem

#1
[eluser]GamingFusion[/eluser]
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

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&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;
&lt;/head&gt;

&lt;body&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>
        
        <div class="sidebar">
            <center><h3>Menu</h3></center>
            <hr />
            <ul>
            <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>
            &lt;?php
                if (isset($isLoggedIn))
                {
                    echo '<li>' . anchor('members/profile', 'Profile') . '</li>';
                    echo '<li>' . anchor('members/logout', 'Logout') . '</li>';
                }
                else
                {
                    echo anchor('members', 'Staff Login');
                }
            ?&gt;
            <li><a href="mailto:[email protected]">Report a Bug</a></li>
            </ul>

        </div>
        
        <div class="content">

and here is the template file you you dont quite understand
Code:
&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;

#2
[eluser]bigtony[/eluser]
How are you loading the $isLoggedIn variable? Presumably it's being stored in the session, so you could just check that in your view:
Code:
&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;

#3
[eluser]GamingFusion[/eluser]
yes it is stored in a session. I will try that when i get home. Thanks man

#4
[eluser]GamingFusion[/eluser]
yup it work


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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