Jump to content

[SOLVED] session problem -(nightmare) urgh!


meltingpoint

Recommended Posts

I have protected pages that have this code at the start of each page

<?php
$access_level 	= 6; // Change to a higher group number if required
include("tfc_paths.php");
$ip						= $_SERVER['REMOTE_ADDR'];
require ($login_path."/tfc_user_perm_check.php");
?>

 

tfc_paths.php is;

<?php
$sec_path 	='/home/andy128/select';
$site_path	='/home/andy128/public_html/XXXXXXXX.com';
$login_path	='/home/andy128/public_html/XXXXXXXX.com/tfc_login';
?>

 

and tfc_config.php is;

<?php
$no_access							="<center><br><br>I am sorry- you do not have sufficient privileges to view this page.<br>To return to the <strong>Landing Page</strong>- <br><br>click on the <strong>Landing Page Link</strong> link to the left.<br><br>If you have questions or to report problems<br>-- please contact the Website Administrator.</center>";
$ip_security						="<center><br><br>There is a security problem with your session and the IP address.  Please notify the site Administrator.</center>";
$sign_in								="<center><br><br>To reach this page- you must be a member and sign in. Please go to the Main Page and sign in.</center>";
$site_administrator		= 'keith.andersen@gmail.com';
//
$tfc_file1								= $sec_path."/tfc_arrest_db.txt";
$tfc_file2								= $sec_path."/tfc_vehicle_db.txt";
$tfc_file3								= $sec_path."/tfc_additional_case_data_db.txt";
$tfc_file4								= $sec_path."/tfc_users_db.txt";
$tfc_file5								= $login_path."/login_log.txt";
//
function sanitize_data($var)
{
$var			= trim(strip_tags($var));
$bads 		= array("{" , "[" , "`" , "<" , ">" );
$var 			= str_replace($bads, "" , $var);
return $var;
}
//
?>

 

and the tfc_user_perm_check.php is

<?php
session_start();
//
include $sec_path."/tfc_config.php";
//
//
if(empty($_SESSION['Susername']))
	{
	$message = $sign_in;
	include ( $login_path."/message_page.php");
	session_destroy();
	exit;
	}
//
//
if (substr_count($_SESSION['Sperm'], $access_level) != 1  ) 
			{
			$message = $no_access;
			include ( $login_path."/message_page.php");
			exit;
			}

//--------Check to see if the SESSION IP and the USERS IP still match--------------
//
if($_SESSION['ip'] !== $ip)
		{
		$message = $ip_security;
		include ( $login_path."/message_page.php");
		session_destroy();
		exit;
		}

?>

 

with things just as they are- the first time you sign in- it defaults to the message where Susername is empty.  Log out and try again- it works fine.

For some reason- I can only get the session variables to go one page.  Upon trying to go to a third page- the session is ended and it reverts to the Susername is empty message.

 

Any suggestions would be welcome.

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.