Guest Posted June 30, 2010 Posted June 30, 2010 I have a problem that doesn't seem to make sense. Sometimes when I load the front end of my site, I get the following script error alert filling the page Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /xxxxxxx/xxxxxxx/public_html/catalog/includes/functions/sessions.php on line 127 I don't recall ever editing anything in the sessions.php file and what's even stranger, if I refresh the page, it loads just fine with no errors. Anyone have any ideas what could be causing this? I'm going slightly nuts trying to figure it out and I know this is losing me sales. Edit: I found line 127 in sessions.php and this is the funtion that's giving me the trouble. Maybe someone with more smarts then me can tell me why it's happening function tep_session_is_registered($variable) { if (PHP_VERSION < 4.3) { return session_is_registered($variable); } else { return array_key_exists($variable, $_SESSION); } }
MrPhil Posted July 1, 2010 Posted July 1, 2010 Did your host just upgrade PHP? Possibly to 5.x? It sounds like there are some code changes needed to be compatible with recent PHP versions, such as 5.3. $_SESSION is a "superglobal" array that has been around since PHP 4.1.0, so your system ought to have it defined. If the problem is intermittent, I would toss it over the wall to your host, as it sounds like a server problem. In the meantime, exactly what osC version, and what PHP version, are you using? From the PHP manual page on $_SESSIONS (http://php.net/manual/en/reserved.variables.session.php), "Please note that if you have register_globals to On, global variables associated to $_SESSION variables are references, so this may lead to some weird situations." Perhaps PHP 5.3 is choking on something because you still have register globals on? If you're using osC 2.2 RC1 or later, turn off your register globals and see if matters improve. If you're still at 2.2 MS2 or earlier, and won't upgrade, you'll have to install the add-on for eliminating register global use.
Guest Posted July 1, 2010 Posted July 1, 2010 Thanks The server is running 5.2.13 Running rc2 scripts with minimal contributions. I was kinda leaning toward a server problem from the onset, from what limited php knowledge I have I'm guessing that function is looking for cookies or exiting session info, and if you have no cookies for the site the error pops up. Thanks again for the info, I'll let ya know what happens.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.