sess_write() broken on login when using Pressflow

bl444137 - September 23, 2009 - 15:30
Project:Memcache API and Integration
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

sess_write() seems to be broken on login when using Pressflow. I am not experiencing these problems with vanilla Drupal...

When the user first attempts to log in, a cookie gets set in the browser, but nothing gets written to the session bin, and the user is not recognized as an authenticated user.

If the user immediately tries to log in again, i.e. when there is already a cookie set in the browser, at that point, the session is written correctly to the session bin.

Upon further examination of the sess_write() code:

function sess_write($key, $value) {
  global $user;

  // If the client doesn't have a session, and one isn't being created ($value),
  // do nothing. If session saving has been turned off, do nothing.
  // Cases 1a, 1c, and 2c are covered here.
  if ((empty($_COOKIE[session_name()]) && empty($value)) || !session_save_session()) {
    return TRUE;
  }

If I add an additional check for $user->uid == 0 (which is also the way recent versions of Drupal's session.inc code does it)

if (!session_save_session() || ($user->uid == 0 && empty($_COOKIE[session_name()]) && empty($value)))

the problem for Pressflow is resolved.

I am aware that this problem is probably related to Pressflow's changes, however, I think check should be there anyways.

AttachmentSize
memcache-session.inc_.patch597 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.