diff -u b/modules/system/system.install b/modules/system/system.install --- b/modules/system/system.install +++ b/modules/system/system.install @@ -3173,22 +3173,14 @@ ); db_drop_primary_key('sessions'); db_change_field('sessions', 'sid', 'sid', $spec, array('primary key' => array('sid', 'ssid'))); - $sessions = db_query('SELECT sid, ssid FROM {sessions}'); - while ($session = $sessions->fetchAssoc()) { - $query = db_update('sessions'); - $fields = array(); - if (!empty($session['sid'])) { - $fields['sid'] = drupal_hash_base64($session['sid']); - $query->condition('sid', $session['sid']); - } - if (!empty($session['ssid'])) { - $fields['ssid'] = drupal_hash_base64($session['ssid']); - $query->condition('ssid', $session['ssid']); - } - db_update('sessions') - ->fields($fields) - ->execute(); - } + + // Delete all the existing old sessions. + db_truncate('sessions')->execute(); + // Force to write again the current session to have it hashed. + drupal_save_session(TRUE); + _drupal_session_write(session_id(), ''); + drupal_save_session(FALSE); + } /**