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		= '[email protected]';
//
$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
https://forums.phpfreaks.com/topic/174269-solved-session-problem-nightmare-urgh/
Share on other sites

To add to this..............on freshly opened browser the session variables do not pass from page to page.  However, if I log_out of the session and then log back in- the variables pass from page to page with no problem for all users.

 

Weird

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.