views:

40

answers:

2

I have one of my pages redirect to a page called customproofs.php.

When it redirects to that page, the following Warning message appears:

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

Does this mean I need to change something in the php.ini file? How would I change the php.ini file for a specific folder on a web server?

Is changing the setting just so the message goes away? Why am I receiving this message?

The code works fine as it is now. Could I just tell the warning not to appear?

+4  A: 

You can avoid this by not using the same names for session variables and regular variables.

e.g. if you had

$foo = 'Hello';
$_SESSION['foo'] = 'Bar';

try changing this to:

$foo = 'Hello';
$_SESSION['session_foo'] = 'Bar';
denrk
What is wrong with using a variable named $address and another variable named $_SESSION['address']?
zeckdude
@zeckdude that's a long story. you'd better do that. Or at least initialize your $_SESSION['address'] with non-null value.
Col. Shrapnel
+1  A: 

This is pretty odd error message.
To avoid this one and many other pitfalls, just never the same names to the session variable and a global variable. I.e. Having in the same script variables $_SESSION['cart'] and $cart is wrong, while $_SESSION['sess_cart'] and $cart is all right.
Also, I hope you don't use ancient session syntax, session_register() one

Col. Shrapnel