enkidu72 Posted December 26, 2007 Share Posted December 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/ Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 Sessions look fine. Verify in your new PHP.INI that the session save path is correct. Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423485 Share on other sites More sharing options...
enkidu72 Posted December 26, 2007 Author Share Posted December 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423509 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 Put session_start(); as your first line of code. Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423510 Share on other sites More sharing options...
enkidu72 Posted December 26, 2007 Author Share Posted December 26, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423512 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 Needs to be on every page you want sessions to work in. Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423517 Share on other sites More sharing options...
enkidu72 Posted December 26, 2007 Author Share Posted December 26, 2007 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 ... Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423524 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 Put it in your login.php and see if it works. If it still doesn't then do more troubleshooting to determine sessions do work, like making two new pages with just sessions and make sure they pass. Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423526 Share on other sites More sharing options...
enkidu72 Posted December 26, 2007 Author Share Posted December 26, 2007 Ok I'll try that . Many thx revraz David Quote Link to comment https://forums.phpfreaks.com/topic/83252-session-not-working-migrating-from-php4-to-php5/#findComment-423529 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.