morthor Posted March 2, 2009 Share Posted March 2, 2009 i have a huge problem, my web page is full of $_SESSION vars and the problem is... i updated my server with Apache 2.2.8 and PHP 6.0.0-dev and will not accept the register_session and $_SESSION, so i need some way to recover all that vars... before this problem make's me sick... and sorry about my english... Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/ Share on other sites More sharing options...
trq Posted March 2, 2009 Share Posted March 2, 2009 session_register has long been depricated and in fact will not work with register globals switched on. Register globals has been completely disabled in 6, so I'd say thats your problem. Otherwise, were going to need to see some example code. Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774750 Share on other sites More sharing options...
morthor Posted March 2, 2009 Author Share Posted March 2, 2009 ok the next code check password and login from students, and register some Session vars.... $alumnos=mysql_query("SELECT * FROM users WHERE nick='$_POST[LOG]' and pass='$_POST[PSW]' "); if(is_numeric($psw{1}) and is_numeric($psw{4}) AND $user_ok = mysql_fetch_array($alumnos)) { //comprobamos en la db si existe ese nick con esa pass session_register("usuario"); //registramos la variable usuario que contendrá el nick del user session_register("email"); //registramos la variable idusuario que contendrá la id del user session_register("level"); //registramos la variable level que contendrá el level del user session_register("clave"); //registramos la clave del alumno session_register("permiso"); //registramos los permiso para califs //damos valores a las variables de la sesión $_SESSION[usuario] = $user_ok["nick"]; //damos el nick a la variable usuario $_SESSION = $user_ok["email"]; //damos la id del user a la variable idusuario $_SESSION[level] = $user_ok["level"]; //damos el level del user a la variable level $_SESSION[clave] = $user_ok["id"]; //damos el id a la variable clave $_SESSION[permiso] = $user_ok["give"]; //damos el give a la variable permiso Header("Location: 07alumno/2alumno.htm"); //volvemos al login donde nos saldrá nuestro menú de usuario } the problem is all pages need this vars to work properly, for example this code, says me the student classroom <? //Let the Goddamn game begins session_start(); include '../coneccion.php'; $base0=mysql_query("SELECT * FROM alu_st WHERE ID=$_SESSION[clave]"); $pre0=mysql_fetch_array($base0); if($pre0[skin]==0) { $i=1; $az=0; if($_SESSION[clave]>=1000 and $_SESSION[clave]<=2000) { $z=1; } elseif($_SESSION[clave]>=2000 and $_SESSION[clave]<=3000) { $z=2; } elseif($_SESSION[clave]>=3000 and $_SESSION[clave]<=4000) { $z=3; } elseif($_SESSION[clave]>=4000 and $_SESSION[clave]<=5000) { $z=4; } elseif($_SESSION[clave]>=5000 and $_SESSION[clave]<=6000) { $z=5; } elseif($_SESSION[clave]>=6000) { $z=6; } so every page in my web need this vars, and i have aprox 200 php's and encode all of 200... just imagine I hope this have a solution FOR YOUR TIME THANKS BRO Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774813 Share on other sites More sharing options...
trq Posted March 2, 2009 Share Posted March 2, 2009 Remove all the lines containing session_register(), you don't need them. Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774819 Share on other sites More sharing options...
phant0m Posted March 2, 2009 Share Posted March 2, 2009 and always put the key in quotes: $_SESSION['usuario'] and NOT $_SESSION[usuario]! Without the quotes, it might be considered a constant, but PHP in that case, php is mostly tolerant. However, I don't know whether it still is in 6.0 Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774822 Share on other sites More sharing options...
PFMaBiSmAd Posted March 2, 2009 Share Posted March 2, 2009 Any page that sets or references a $_SESSION variable must have a session_start() statement in it before any content is output. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON to get php to help you with problems it finds when your code runs. Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774848 Share on other sites More sharing options...
morthor Posted March 2, 2009 Author Share Posted March 2, 2009 ok my final code after the corrections $maestros=mysql_query("SELECT * FROM maestros WHERE nick='$_POST[LOG]' and pass='$_POST[PSW]' "); if($user_ok = mysql_fetch_array($maestros)) //si existe comenzamos con la sesion, si no, al index { //session_start(); //damos valores a las variables de la sesión $_SESSION['usuario'] = $user_ok["nick"]; //damos el nick a la variable usuario $_SESSION['email'] = $user_ok["email"]; //damos el email que determinara el salon $_SESSION['level'] = $user_ok["level"]; //damos el level del user a la variable level $_SESSION['periodo'] = $user_ok["periodo"]; //damos al periodo a la variable de sesion Header("Location: 09personal/schuler.php"); //volvemos al login donde nos saldrá nuestro menú de usuario } and this is Shuler.php session_start(); /*NOTA: aqui solo se hace una mera redireccion de la sección*/ if ($_SESSION[level] == 3) Header("Location: mainmaestros.htm"); elseif($_SESSION[level] == 4) Header("Location: secres.htm"); elseif($_SESSION[level] == 3 and $_SESSION == 91) Header ("Location: compu.htm"); elseif($_SESSION[level] == 4 and $_SESSION == 99) Header ("Location: psico.htm"); else echo $_SESSION[level]; //Header ("location: ../denaid.htm"); the problem is aparently solved, but here put echo because dont send session var, always sendme to denaid... so thats why i comment that codeline... so what is the problem here??? Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774884 Share on other sites More sharing options...
trq Posted March 2, 2009 Share Posted March 2, 2009 session_start() is commented out in the first file. Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-774981 Share on other sites More sharing options...
morthor Posted March 2, 2009 Author Share Posted March 2, 2009 Holy God man!!!! THANKS WORKS PERFECTLY Thanks for your time and your comments. Link to comment https://forums.phpfreaks.com/topic/147582-solved-php-600-dev-_session-problem/#findComment-775008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.