Jump to content

Include Problems


atlanta

Recommended Posts

Hi,

I'm having a little problem with the script i was writing for a site...

i have a right navbar include for the right side of the site

and in the rigth include i have my session file included within that.

 

ok my problem comes in when i run my if user is logged in function

if i call the file along in the browser rightnav.php it runs fine checks the user correctly and displays the correct info

but when i just view the main page with the rightnav.php included on it the function doesnt work and it just displays

if user wasnt logged in ... any body ever ran into this problem or know how to fix it?

 

I believe theres an error when i include the session file while its included on the main page but my server wont out errors at all even after using error_reporting(E_ALL); no php errors show..

Link to comment
https://forums.phpfreaks.com/topic/108625-include-problems/
Share on other sites

ok yea i do have that on all pages and was just about to add some

 

heres my rightnav.php file

 

<?
session_start();
include('session.php');
?>

<div class="sideheader">Members</div>



<ul class="sideul">

<center>

Total Members: <? echo $database->getNumMembers(); ?>

<br />

Members Online: <? echo $database->num_active_users + $database->num_active_guests; ?>

<br />

Layouts: 
<? echo $database->Layouts(); ?>
<?
if($session->logged_in){
   echo "LOGGED IN";
}
else
{
echo "LOGGED OUT";
}
?>

<li><a href="http://www.stickamstuff.com/members.php">Login</a></li>

<li><a href="http://www.stickamstuff.com/register.php">Register</a></li>

<li><a href="http://www.stickamstuff.com/process.php?logout=1">Logout</a></li>

</center>

</ul>


 

$session->logged_in function

function logged_in(){
      global $database;  //The database connection
      /* Check if user has been remembered */
      if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){
         $this->username = $_SESSION['username'] = $_COOKIE['cookname'];
         $this->userid   = $_SESSION['userid']   = $_COOKIE['cookid'];
      }

      /* Username and userid have been set and not guest */
      if(isset($_SESSION['username']) && isset($_SESSION['userid']) &&
         $_SESSION['username'] != GUEST_NAME){
         /* Confirm that username and userid are valid */
         if($database->confirmUserID($_SESSION['username'], $_SESSION['userid']) != 0){
            /* Variables are incorrect, user not logged in */
            unset($_SESSION['username']);
            unset($_SESSION['userid']);
            return false;
         }

         /* User is logged in, set class variables */
         $this->userinfo  = $database->getUserInfo($_SESSION['username']);
         $this->username  = $this->userinfo['username'];
         $this->userid    = $this->userinfo['userid'];
         $this->userlevel = $this->userinfo['userlevel'];
         return true;
      }
      /* User not logged in */
      else{
         return false;
      }
   }

Link to comment
https://forums.phpfreaks.com/topic/108625-include-problems/#findComment-557129
Share on other sites

just did a little testing and found that if i use this if

 

if(isset($_SESSION['userid']) && isset($_SESSION['username'])){

echo '<li><a href="http://www.stickamstuff.com/members.php">My Page</a></li>';

}

 

it doesnt echo but if i take out $_SESSION['userid'] it echos

 

but thats only when its included on the main page .

it echos with both if i go directly to the page.

Link to comment
https://forums.phpfreaks.com/topic/108625-include-problems/#findComment-557130
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.