1

Possible Duplicate:
PHP session side-effect warning with global variables as a source of data

I am getting following warning from php

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 believe the following codes created the warning.

 $name=$_SESSION['name'];
 $emails=$_SESSION['email'];

 $_SESSION['info']=array_intersect($name, $emails);

I have no access to php.ini nor server. I can only change my codes. Are there anyways to remove the warning?

0

2 Answers 2

3

This means you have a variable with the same name as your session variable is as below.

$_SESSION['variable'] = null;
$variable = 'data';

You can stop PHP from trying to find existing variables and warning you about them by adding these lines to your script in php.ini or .htaccess

ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
Sign up to request clarification or add additional context in comments.

Comments

2

This will remove the error:

ini_set('session.bug_compat_42',0);
ini_set('session.bug_compat_warn',0);

You may also be able to turn it off from within your .htaccess file or, if available, a php.ini file in the root of your directory.

2 Comments

Is just suppressing the error a good idea? It seems like it might come back to haunt them later.
@GigaWatt true. I would update the question but I'll just vote to close due to being a dupe.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.