Jump to content

PHP Member header Include


offdarip

Recommended Posts

I have a header as a include at the top of each page. When a member is NOT logged in, it displays a header with login option and some non member links, when member IS logged in it displays a header with member options. That part of the script works fine, however when i log in on that page and the member header is displayed.. If i visit another page or refresh that page it loses the session like its been logged out and just displays the standard header. Any help would be greatly appreciated.

 

index.php

<?php 
session_start();
$path = (isset($_SESSION['LOGINID']) ) ? 'memberheader.php' : 'header_tmp.php';

include( $path ); 

?>

 

this is the auth script included in the member header

memberheader.php

<?php
require_once('scripts/auth.php');
?>

 

auth.php (the actual auth script)

<?php
//Start session
session_start();{


}


if(!isset($_SESSION['LOGINID'])) {
	header("location: access-denied.php");
	exit();
}
?>

 

I didn't include login page because the login script works fine on each page except the ones with the multi header include. The pages that only include the memberheader works fine

Link to comment
Share on other sites

It isn't clear what's going on.

 

A user goes to the index page logged out. They then login using a script you haven't provided.

 

They then get redirected... where? And are they still logged in at this point?

 

Is "memberheader.php" a file that only has the script require_once('scripts/auth.php');? If so, why not just have require_once('scripts/auth.php'); in each of the pages that need it, and ditch memberheader.php entirely?

Link to comment
Share on other sites

  • 2 weeks later...

the login portion of it works fine which is why i did not post that portion of the script. I need the member header because it provide tools and options only available for members and the guest header will allow user to log in.

 

It redirects to the same page. Initially it shows it is logged in, but if i got to another page or refresh that page it goes back to the guest header and is logged out

Link to comment
Share on other sites

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.