Problems with $_SESSION

Asked

Viewed 77 times

1

I have a problem to solve. I have the same site on several different servers, but one has different results. It seems there is some error, I do not know if it is configuration.

Here’s the following test code I did:

session_start();  
if(!isset($_SESSION["funcio"]) || !isset($_SESSION["senha"])){  
require_once "sair.php";  
}  
print $_SESSION["funcio"];  
$_POST['funcio'] = '1';    
$funcio = '2';  
print $funcio;  
print $_POST['funcio'];  
print $_SESSION["funcio"];  

Results:
On the sites that work normally the result is

Admsite 2 1 Admsite

On the website that presents problem, the result is

Adm 2 1 2

Conclusion: When declaring the $funcio variable with the same name as the $_SESSION["funcio"] and define its value, $_SESSION["funcio"] assumes the value of the variable $funcio. This is giving me a great upset. I ask for help to resolve this issue. I have already looked at php.ini And on both servers it’s pretty much the same. Hugs


already checked, the values of $_SESSION["function"] are correct, but on this server, when I create a $function variable and define its value, the variable $_SESSION["function"] assumes the value of the created variable.

I realized that this occurs not only with this variable, but with all variables of type $_SESSION whose name is the same of variables that I create.

What will that be?

  • You’re not entering the if ? condition because if you do, you might be able to leave.php something from an echo 2 and print on that one

  • You are not entering the if condition, if you had, you would leave the program. Because.php leaves the page and eliminates all variables. There in the case, it still prints the values of the variables.

  • And how’s the setup register_globals? It seems that it is active. If yes, avoid using it, because it is obsolete.

  • register_globals = Off

  • I have already checked, the values of $_SESSION["function"] are correct, but on this server, when I create a $function variable and define its value, the variable $_SESSION["function"] assumes the value of the created variable. I noticed that this occurs not only with this variable, but with all variables of type $_SESSION whose name is the same of variables that I create. What will that be?

  • The configuration register_globals = Off is on this server? What version of PHP?

  • In what is giving error the version is PHP Version 5.3.26, in what is giving correctly the version is PHP Version 5.2.17. register_globals = Off is in php.ini, but I will check in php settings.

  • After giving the phpinfo() command, I checked that register_globals is on, but php.ini is off. How to resolve this issue?

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.