Saturday, September 30, 2006

I get an "Warning: Unknown:" error message at the bottom of the page

Question:
I get an "Warning: Unknown:" error message at the bottom of the page
when I log in to the page.

"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"

Solution:

Below is the solution to this problem:

The session_register() function references global variables itself.
Instead set the session variable directly to use the SUPER GLOBAL
"$_SESSION" variable.

Example:

session_register('loginName');

should be re written as:

$_SESSION['loginName'] = $loginName;

Note: You can still use the session_is_registered() and
session_unregister() functions when you set the variable directly in the $_SESSION
super global.

No comments: