Jump to content

session not working migrating from php4 to php5


enkidu72

Recommended Posts

Hi all ...

I have this problem ,  I can't authenticate no more with an app I wrote some time ago ...

Everything used to work fine in PHP4 , but when I switched to PHP5 stopped working ...

 

This is login.php


<?php 
$pageTitle = null;
$pageContent = null;
$loginForm = 1;

if (!isset($login_message)) { $login_message = "" ; }
if (isset($_SESSION['logged']) && $_SESSION['logged']=='1') {
$loginForm = 0;
}

if (isset($_POST['user'])&& isset($_POST['passwd'])){
include_once ("admin_config.php");
$user=mysql_real_escape_string(trim(strip_tags($_POST['user'])));
$passwd=mysql_real_escape_string(trim(strip_tags($_POST['passwd'])));
$connect ;
$selectdb ;
$result = mysql_query("SELECT user,passwd,is_admin FROM utenti WHERE user='$user'")
or die(mysql_error("Login Incorrect"));
$valid=array();
while($row = mysql_fetch_array( $result )) {
	$valid['user'] = $row['user'];
	$valid['passwd'] = $row['passwd'];
	$valid['perms'] = $row['is_admin'];

}
if (isset($valid['user'])) {
	if ( $user==$valid['user']) {
		if ($valid['passwd']==$passwd){ 
		$_SESSION['user']=$valid['user'];
		$_SESSION['logged']=1;
		$_SESSION['perms']=$valid['perms'];
			if ( $valid['perms']==1) { include ("admin_content.php");
			}
		$loginForm = 0;		 
		}	
	}
} 
} 
if ($loginForm == 1){ 
include ("auth_box.php");
echo $login_message ;
}
?>

 

 

Some idea ?

 

Thx in advance

 

David

thx revraz ...

No errors in /var/log/apache2/error_log ...

 

in php.ini this is the path of session.save :

session.save_path = "/var/lib/php"

 

This is the content of /var/lib/php :

 

root@andromeda:~# ls -lah /var/lib/php/

total 512

drwxrwx---  2 nobody nobody 192 2007-12-26 18:29 ./

drwxr-xr-x 30 root  root  744 2007-06-29 07:28 ../

-rw-------  1 nobody nobody  0 2007-12-13 01:30 sess_08qp9iq4asj3ltas10padfgde6

-rw-------  1 nobody nobody  0 2007-12-26 18:27 sess_95ac2qdqg03pm3e28askuq6eh6

-rw-------  1 root  root    0 2007-12-26 18:29 session_mm_apache2handler0.sem

 

Some hint ?

 

Thx

 

David

 

session_start() it's the first line in index.php ...

Maybe something wrong in here ?

 

<?php
session_start();
header("Cache-Control: no-cache, must-revalidate"); 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/biblio.css" />
</head>

<body>

<div id="wrapper">
<div id="header"> 
<?php
include ("header.php");
if(isset($_REQUEST['p'])){
$p = $_REQUEST['p'];
switch ($p) {
case 'logout':
		$_SESSION['logged']='0';
		$_SESSION['user']="";
	break;
case 'gest_utenti':
		$pageName = "gest_utenti.php";
	break;
case 'mod_utenti':
		$pageName = "mod_utenti.php";
	break;
case 'add_utenti':
		$pageName = "add_utenti.php";
	break;
case 'del_utenti':
		$pageName = "del_utenti.php";
	break;
case 'add_libro':
		$pageName = "add_libro.php";
	break;
case 'search_simple':
		$pageName = "search_simple.php";
	break;
case 'search_advance':
		$pageName = "search_advance.php";
	break;
case 'log_show':
		$pageName = "log_show.php";
	break;
case 'dump_db':
		$pageName = "dump_db.php";
	break;

default:
		$pageName = "welcome";

}
}
?>
</div>



<div id="sidebar">
<?php
include ('login.php');
if (isset($_SESSION['logged']) && $_SESSION['logged']=='1') {
include ('admin_menu.php');
}
?>
</div>

<div id="content"  >

<?php
include ("content.php");
?>
</div>

<div id="footer">
<?php
include ("footer.php");
?>
</div>



</div>

</body>
</html>


index.php includes all other pages ...

[...]
<?php
include ('login.php');
if (isset($_SESSION['logged']) && $_SESSION['logged']=='1') {
include ('admin_menu.php');
}
?>
[...]

Shouldn't this works this way ?
And what I really can't understand it's why worked fine with apache 1.3 and php 4 before ...


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.