Help with: PHP Warning: Unknown: Your script possibly relies on a session side-effec


I have followed (except with the change of details) a script fragment from PHP MySQL 4th Edition. It is shown below:

$thispage = "contact";
$cart = '';
$notice = '';
$order = NULL;
if (isset($_SESSION['cart'])) {
    $cart = $_SESSION['cart'];
    $notice = "<b>Most parts have a left and right side. If you only intend to order one or the other, please delete the side not required. Also, <span style='color:red;'>please change the Enquiry Type to either &ldquo;Parts Order&rdquo; or &ldquo;Parts Enquiry&rdquo;.</span> Remember to fill in your details at the top of the form. Thank you.</b>";
    $order = "Parts Order";
    $enquiry = "Parts Enquiry";

I am getting the error message:

[31-May-2012 15:23:38] 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

Apart from no knowing how to fix this, I am also not sure where line 0 would be. Is it something I should worry about, or can I just let it ride. I know it is possible to live with PHP Notices, but am also not sure about Warnings.

I have checked in the manual, and it seems that register_globals is a bad thing. But I haven’t a clue how to avoid getting this warning.


I read somewhere that someone had that issue when they used a global variable name for a session variable. Try renaming either $_SESSION[‘cart’] or $cart.

Wow, thank you very much! Not only did that fix the problem, but I also now understand the meaning of the Warning message. Another little piece of the jigsaw in place.

NP :slight_smile: