I just unexpectedly start with the strangest problem I have ever seen, and nothing has changed except the host of my site. I use many $ _SESSION variables in my code, which may have the same name as a normal variable, but usually changing a normal variable changes the $ _SESSION variable with the same name.
For example, if I do
$_SESSION['favcolor'] = 'blue'; $favcolor = 'green'; echo $_SESSION['favcolor'];
I get green as an answer ... How can I prevent this from happening? I suppose, most likely, some kind of PHP ini variable that needs to be changed, but I cannot find anything in this ...
Decision
So, since I am on a different host to host my site, I had to go through this as follows. I created a php.ini and placed it in the root of my site files with only the following line:
register_globals = Off ;notice the capital 'O' in 'Off'
Then, in my .htaccess file, I added this to the end of the file:
<IfModule mod_suphp.c> suPHP_ConfigPath /home/myhostusername/public_html/stumpyinc.com <Files php.ini> order allow,deny deny from all </Files> </IfModule>
No more conflicting variables! I also learned something from this experience and did some further research; variables and session variables should never be the same. This is a good practice that I will start using throughout my programming.
source share