session var not being passed?

From: Date: Fri, 12 Dec 2003 21:48:46 +0000
Subject: session var not being passed?
Groups: php.general 
Request: Send a blank email to php-general+get-172603@lists.php.net to get a copy of this message
New set of eyes maybe or maybe I am indeed regressing... Page calling functions looks like such... <?php require 'sessions.php'; require 'inc.php'; if (($_SESSION['user'] == "") || ($_SESSION['pass'] == "") || ($_SESSION['lvl'] == "")) { $_SESSION['msg_01'] = "You have not entered the correct authorization information. Please enter your user name, password & department ID."; $_SESSION['msg'] = $dberrors[1]; call_user_func("db_logs"); //call_user_func("exit_app"); } elseif (($_SESSION['user'] != "") || ($_SESSION['pass'] != "") || ($_SESSION['lvl'] != "")) { if ((strlen($_SESSION['user'] >= 255)) || (strlen($_SESSION['pass'] >= 255)) || (strlen($_SESSION['lvl'] >= 255))) { $_SESSION['msg'] = $dberrors[3]; call_user_func("db_logs"); call_user_func("exit_app"); } elseif ((strlen($_SESSION['user'] <= 255)) || (strlen($_SESSION['pass'] <= 255)) || (strlen($_SESSION['lvl'] <= 255))) { $_SESSION['msg'] = $dberrors[10]; call_user_func("db_logs"); call_user_func("menu"); } else { $_SESSION['msg'] = $dberrors[11]; call_user_func("db_logs"); call_user_func("exit_app"); } } else { $_SESSION['msg'] = $dberrors[8]; call_user_func("db_logs"); call_user_func("exit_app"); } ?> Then in body of page I call <?php call_user_func("dhcp_vlans"); ?> Now the contents of inc.php is below (at least the "menu" and "dhcp_vlans" functions) <?php function menu() { $lvl = base64_decode($_SESSION['lvl']); if ($lvl == "view") { $_SESSION['menu'] = "custom menu 01"; $_SESSION['lvl'] = base64_encode($lvl); } elseif ($lvl == "user") { $_SESSION['menu'] = "custom menu 02"; $_SESSION['lvl'] = base64_encode($lvl); } elseif ($lvl == "admin") { $_SESSION['menu'] = "custom menu 03"; $_SESSION['lvl'] = base64_encode($lvl); } else { $_SESSION['menu'] = "custom menu 04"; } $_SESSION['lvl'] = base64_encode($lvl); // recreate session variable for more checks } function vlans_dhcp() { $lvl = base64_decode($_SESSION['lvl']); // this session variable is dissapearing from the second nested if / elseif statement? if ($lvl != "admin") { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } elseif ($lvl == "admin") { $_SESSION['lvl'] = base64_encode($lvl); if ($_POST == "") { $_SESSION['lvl'] = base64_encode($lvl); session_unset($_SESSION['list']); ,....create automatic form..."; $_SESSION['lvl'] = base64_encode($lvl); //unset($table,$sql,$db_vlans,$vlans,$x); } elseif ($_POST != "") || (isset(var)) { //What happened to my session 'lvl' var? ...creat different form... } elseif ($_POST != "") { session_unset($_SESSION['list']); require 'dbase.php'; $table = "subnets"; $_SESSION['list'] = "...different form again..."; //unset($table,$db_vlans,$vlans,$i,$x); } else { $_SESSION['lvl'] = base64_encode($lvl); header("Location: login.vlans.php"); } } else { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } } ?>

« previous php.general (#172603) next »