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?

Community
  • 1
  • 1
FlyingCat
  • 14,036
  • 36
  • 119
  • 198

2 Answers2

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);
Techie
  • 44,706
  • 42
  • 157
  • 243
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.

Prisoner
  • 27,391
  • 11
  • 73
  • 102