Jump to content

[SOLVED] Session problem with php5


steenkybastage

Recommended Posts

Hello, I am migrating an account from a php 4 (I believe it was 4.4.4) server to a new server that is running php 5.1.6 as well as my testing server which is running 5.2.3.

 

Anyhow, the old and new production servers are running fine, but I cannot figure out what is the problem with my testing server and (I assume) sessions.

 

The following code (chopped WAY down from original) seems to be my issue on the testing server: (I think the issue is with the third page, "session.php" and it not seeming to get the session info)

 

login.php:

<?php 
session_start();
$_SESSION['website'] = "a";
//PROCESS LOGIN
$msg = "";
if (isset($_POST['password'])){
//check for password
if (empty($_POST['password'])){
	$p = false;
	$msg = 'Please fill in password.';
} else {
	$p = $_POST['password'];
	$Password = 'testing';
		if($p == $Password){	
			//password matches
			$sessiongaccess = $GalleryAccess;
			$sessionpaccess = $SplashAccess;
			$sessiontaccess = $TestAccess;
			$sessionuser = $Name;
			session_register("sessionuser");
			session_register("sessiongaccess");
			session_register("sessionpaccess");
			session_register("sessiontaccess");

			$_SESSION['gaccess'] = $GalleryAccess;
			$_SESSION['paccess'] = $SplashAccess;
			$_SESSION['taccess'] = $TestAccess;
			$_SESSION['sessionuser'] = $Name;
			$_SESSION['sessionHelp'] = $_POST['help'];
			header("Location: index.php");
			exit();
		} else {
			$msg = " Sorry, the password was not entered correctly. The passwords are case sensitive.";
	}
}	
}
?>
Some text here to build the page/form

 

index.php:

<?php
include('session.php');
$_SESSION['website'] = "a";
echo "working";
?>

 

session.php:

<?php
session_start(); 
if(!isset($_SESSION["sessionuser"])){
	header ('location: login.php');
	exit();
}
?>

 

OK... so here's what I've been able to determine. If the session.php is not included, everything works fine. If "!isset" is changed to "isset" (no !), everything works.

 

This leads me to believe that somehow the session information is not getting passed on properly on my testing server. However, it works great on both production servers.

 

I have tried to check php settings between servers, and have switched/played with settings in the php.ini on the testing server to try to fix the problem... but I haven't been able to determine which setting is actually causing this.

 

If anyone has any ideas as to what I'm doing wrong, I would be most appreciative.

 

Thank you.

Link to comment
Share on other sites

Ok, after dinking around with this for a while... I guess my problem is that my session variables are not being passed at all.

 

If I add in code such as this:

			echo "sessiongaccess = $GalleryAccess<br>";
			echo "sessionpaccess = $SplashAccess<br>";
			echo "sessiontaccess = $testAccess<br>";
			echo "sessionuser = $Name<br>";
			echo "sessionuser = ". $_SESSION["sessionuser"]. "<br>";

 

to the original (not shortened) code, it will spit out all the variables WHILE ON THE LOGIN.PHP PAGE. But once I try to put that into the index or session pages, it does not return anything for the variable.

 

So obviously I have an issue... either with this version of php or with a php.ini setting.

 

Does this help narrow down what might be the issue?

 

Thanks.

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.