Drupal 6.17 Login problems with PHP 5.2

So I upgraded to drupal 6.17 a week or so ago and guess what my hosting company decides to upgrade their PHP to 5.2. Ofcourse as you would know it my drupal instance decides to not work any more. I would try to login as an admin and get prompted right back. I searched for quite a while and finally found a combination that fixed it. I believe the following will fix:

Drupal 6.17
Php: 5.2.13

Add following at the very bottom of index.php:

$GLOBALS['tempUser'] = $user;

Also following dirty patch for includes/session.inc

Index: includes/session.inc
--- includes/session.inc (revision 103)
+++ includes/session.inc (working copy)
@@ -43,12 +43,16 @@
else {
$user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
+ $GLOBALS['account'] = (array)$user;

return !empty($user->session) ? $user->session : '';

function sess_write($key, $value) {
- global $user;
+ global $account, $user;
+ if (empty($user)) {
+ $user = (object)$account;
+ }

$result = db_query("SELECT sid FROM {sessions} WHERE sid = '%s'", $key);

Hopefully it works for you as well if your having this problem too.

Found the fix at: http://drupal.org/node/92802


Leave a Reply