RSS
 

What to do if you see your PHP script relies on session side-effect error message.

24 Aug

I came across this error a few times, enough to where I dug around and finally found the real fix to suppress the error completely.

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 able to suppress the error by properly upsetting a session variable:

  //replace this:
  $_SESSION[$field] = null;

  //with this:
  unset($_SESSION[$field]);

The warning is triggered by assigning to the $_SESSION super global directly. By using unset(…) we are not assign null directly.

VN:F [1.9.3_1094]
Rating: 6.5/10 (4 votes cast)
VN:F [1.9.3_1094]
Rating: +2 (from 2 votes)
What to do if you see your PHP script relies on session side-effect error message., 6.5 out of 10 based on 4 ratings
Retweet
 
Comments Off

Posted in Development, PHP

 

Tags: , , ,

Comments are closed.