Jump to content

Recommended Posts

I have an if/else statement, and a session that is either TRUE or FALSE.

 

If the session is TURE that means the person is logged in, if it is FALSE it means they are not logged in.

 

session_start();
if($_SESSION['isLogged']){
     // Place the Navigation if the user is logged in
}else{
     // Place the Navigation if the user is not logged in
}

 

I would place this in its own file, then include it on all the pages.

My site employs navigation (carefully) based on the URL vars and my index file acts as a quasi-controller including requested pages. Originally, I stored my navigation info (i.e. heirarchy, visibility) in a table so my boss could control the page order and such. I have since abandoned that and created navigation file defining guest nav, as well as logged in nav for 3 different user types. The user access is determined by a session var pulled from the database upon log in. All protected pages start with a function call checking for the right credentials as defined in a security file included on each protected page.

I have an if/else statement, and a session that is either TRUE or FALSE.

 

If the session is TURE that means the person is logged in, if it is FALSE it means they are not logged in.

 

session_start();
if($_SESSION['isLogged']){
     // Place the Navigation if the user is logged in
}else{
     // Place the Navigation if the user is not logged in
}

 

I would place this in its own file, then include it on all the pages.

 

Ok, inside the code block are you using include() files

with different <u><li><a href="index.php">Home</a></li></u>

Somethting like this:

<?php
session_start();
if($_SESSION['isLogged']){
     echo'<a href="index.php">Home</a>
     <a href="myPage.php">My Page</a>';
}else{
     echo'<a href="index.php">Home</a>
     <a href="login.php">Log In</a>
     <a href="register.php">Register</a>';
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.