Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Session variable not globally defined


Recommended Posts

Hi, Has anyone else come across this error, either with the paypal IPN contribs or any other code?


Fatal error: Session variable cart_PayPal_IPN_ID is not globally defined


I am getting it every time i add new code which uses session variables, including some contribs which others seem to use happily.


I have tried turning register_globals off and on with the line


php_flag register_globals 0


in my htaccess files, but it makes no difference. I have the contrib "Register Globals" installed on my store, which is working perfectly, EXCEPT for any new session variable i introduce.


I have tried changing the syntax of session vars to $_SESSION, and have used code from mods and even code written by a third-party affiliate program which others have used, but I get this error everytime a introduce a new session variable.


Does anyone know what that error means?!? Is it a server setup problem?


If anyone has any idea i'd be VERY grateful as no other oscommerce users have reported this error.



Link to comment
Share on other sites

If you check the net, you will find that when ever a forum thread mentions this problem, thats where the thread ends! I think it may be down to those of us with a vested interest in solving it, but its good to know I am not the only one.


A few people have had a look at this for me and everyone is stumped, but having spent the last week on it I have some leads...


Do you have the "Register Globals" contrib installed? Its a work-around for having register_globals set to off in the php.ini file. I suspect this script may have something to do with it.


Is register_globals on or off on your Server?


does this error occur with anything other than session variables? (ie $_SESSION or $HTTP_SESSION_VARS)



Link to comment
Share on other sites



The error doesn't come from php at all! it comes from the "register globals" patch!!!!


The following chunk of code is from the edited version of sessions.php:


if(key_exists($var_name, $var_refs))


if ($map)


// Map global to session variable. If the global variable is already set to some value

// then its value overwrites the session varibale. I **THINK** this is correct behaviour

if (isset($GLOBALS[$var_name]))


$_SESSION[$var_name] = $GLOBALS[$var_name];



$GLOBALS[$var_name] =& $_SESSION[$var_name];




// Unmap global from session variable (note that the global variable keeps the value of

// the session variable. This should be unnecessary but it reflects the same behaviour

// as having register_globals enabled, so in case the OSC code assumes this behaviour,

// it is reproduced here


$GLOBALS[$var_name] =& $nothing;


$GLOBALS[$var_name] = $_SESSION[$var_name];





echo 'Fatal error: Session variable '.$var_name.' is not globally defined<br />';




I don't know how to sort this out yet, but at least we know whats causing it!



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...