PHP error message

I've been using $_SESSION var on this site.  But now I'm getting weird results.

My variable ($_SESSION['Last_Page']) is showing the wrong variable.   I have 2 pages Space_Display and Space_Edit.  They both call "Street_Print.php".  "Street_Print" executes a print inclusion.  I've got rid of the print logic, and the session variable still get;s set to "Space_Edit".  

I'm getting the following error if I select certain pages in a certain order.

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0

The page is hosted on a remote server that I have no control of (HOSTING24.COM)

I've googled "register_global" and it tells me to change the servers php.ini

After more research, will this code work in my "index.php" and flow through all the pages?
php_register_globals=1

Thanks
Glenn
breeze351Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
The page is hosted on a remote server that I have no control of (HOSTING24.COM)
Confused - how can you change anything then?
php_register_globals was removed in PHP v5.4 so you shouldn't be even using that.
0
Ray PaseurCommented:
Danger!  Do not enable Register Globals!  For the background on Register Globals, you may want to read this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html

You can probably just add this to your php.ini file;
session.bug_compat_warn = Off
session.bug_compat_42 = Off

Open in new window

That said, if you visit the pages in a certain order and get a logic failure that is order-dependent, you may have a debugging cycle staring you in the face.  I expect that any such failure would not be related to the warning messages about bug_compat.
0
Dave BaldwinFixer of ProblemsCommented:
The classical problem with $_SESSION variables 'magically' changing values is that you are expecting two windows from the same browser to have different sessions.  They don't.  All windows of a particular browser share the same cookies including Session cookies.  To have two different sessions you need to use two completely different browsers or even machines.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Ray PaseurCommented:
Good point, Dave.  By "two completely different browsers" we mean one instance of Firefox and a different instance of Chrome.  If you have two instances of the same browser, they share the same "cookie jar" file, and this results in unwanted cross-pollination of the session data.  It's an issue that has been before the W3C and may be fixed some day.
0
breeze351Author Commented:
This is not what is happening.
The session vars worked until several days ago.  I can't change the php.ini because it is hosted on "HOSTING24.com"  
This makes sense, because if I change the .ini it changes it to all users.

I'm only using Firefox as the browser.

The error is:

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0

I was told to use "htaccess" to change the "register_global" by HOSTING24.

Where do I go from here?
0
Dave BaldwinFixer of ProblemsCommented:
And we're telling Not to turn register globals on.  You have some other error that is causing that message.  Possibly a variable name that is the same as a $_POST[] variable but is being used in a manner that triggers that message.
http://php.net/manual/en/session.configuration.php#ini.session.bug-compat-42
0
Ray PaseurCommented:
Wow, smh.  DO NOT turn on Register Globals.  Your scripts may start to fail as soon as you do that, or it may take a while, but register globals is dangerous, and Hosting24 is wrong about the cause of these messages.

I am 100% certain you can change this in php.ini without any collateral damage to any site -- yours or any others.  Almost all competently installed PHP servers have php.ini on a per-directory basis, with the WWW root providing the defaults for the site and the sub-directories overriding the root settings.

What level of PHP are you running?  You can use phpinfo() to find out.  Please let us know.

According to this page, these configuration settings can be set according to PHP_INI_ALL.
http://php.net/manual/en/session.configuration.php

According to this page, PHP_INI_ALL settings can be made in the PHP script itself.
http://php.net/manual/en/configuration.changes.modes.php

So please try adding these statements to the top of the errant script and let us know what happens.
ini_set('session.bug_compat_warn', FALSE);
ini_set('session.bug_compat_42', FALSE);

Open in new window

0
breeze351Author Commented:
If I understand your answer:
Layoff the register_global.

When you say that there could be a var name with the same name as a $_POST[] name, I'm not sure what you mean. What would trigger the message?
0
Ray PaseurCommented:
Consider what these variables would mean if you had register_globals set on...  If you haven't read the article about register_globals, it's worth reading to understand the risks associated with something like this.
$id
$_SESSION['id']
$_GET['id']
$_POST['id']

Open in new window

What level of PHP are you running?
0
Dave BaldwinFixer of ProblemsCommented:
In Ray's example above, all four of those would be the SAME variable if register_globals is on.
0
Ray PaseurCommented:
... but subject to the request_order directive (an impossibly stupid idea).  Really, it's hard to program PHP around all of the overlapping configuration options!
0
breeze351Author Commented:
Ray
I'm getting weird results.  Does the code have to be included in every page?
I'm now getting the same error in another page that previously worked!

When you say I need to added it to the script, do you mean on the page or in the inclusion.

I echoed the session variables after I added you code and they are some up as blanks.

I've attache two .php files
"Street_Print.php" get's called from several other pages.
"Setup_Picture_PDF_inc.php" is the PDF print inclusion.

When I delete all the code from "Setup_Picture" and echo the session variables, they all show up as blanks.
0
breeze351Author Commented:
My bad.  I forgot to attach the files.
Street-Print.php
Setup-Picture-PDF-inc.php
0
Dave BaldwinFixer of ProblemsCommented:
Setup-Picture-PDF-inc.php can't work properly because it does not have session_start() at the top of the page.  ALL pages that are involved in a session and use $_SESSION variables MUST have session_start() at the top of the page.  ALL.
0
Ray PaseurCommented:
How to use PHP sessions:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11909-PHP-Sessions-Simpler-Than-You-May-Think.html

You want to create a simple test case -- the SSCCE -- that demonstrates the situation causing the unwanted messages.  And after you see the unwanted messages, add these lines to the top of the simple test case.  Then run it again and see if these settings cure the problem.
ini_set('session.bug_compat_warn', FALSE);
ini_set('session.bug_compat_42', FALSE);

Open in new window

0
Ray PaseurCommented:
For Setup-Picture-PDF-inc.php, try this:
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('session.bug_compat_warn', FALSE);
ini_set('session.bug_compat_42', FALSE);
session_start();
var_dump($_SESSION);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.