Due to the cookie assigned to anonymous users varnish breaks. Is the server side cookie really necessary?

Comments

burgs’s picture

Is there a reason why anonymous users are getting cookies set? Is it not enough to set these variables in cookies/session for users once they're logged in?

repoman’s picture

Just wondering if anyone has had a chance to look at this. I pulled the following data from the sessions table for anon users after deleting all the uid=0 records from the table.

*************************** 83. row ***************************
uid: 0
sid: f70c88bb17e1a78e3becb0c932ffb8b7
hostname: 89.30.105.121
timestamp: 1303325638
cache: 0
session: autologout_hits|a:1:{i:0;i:1303325637;}
*************************** 84. row ***************************
uid: 0
sid: f92545b089f77e5c43556dbb758cebfe
hostname: 66.249.72.153
timestamp: 1303325699
cache: 0
session: autologout_hits|a:1:{i:0;i:1303325697;}
*************************** 85. row ***************************
uid: 0
sid: f9a21c4c609ff9995b7fdef360cbe87b
hostname: 89.30.105.121
timestamp: 1303325620
cache: 0
session: autologout_hits|a:1:{i:0;i:1303325619;}
*************************** 86. row ***************************
uid: 0
sid: fade1fbc2794b61d7b1d4e18f37424be
hostname: 66.249.72.153
timestamp: 1303325424
cache: 0
session: autologout_hits|a:1:{i:0;i:1303325423;}
*************************** 87. row ***************************
uid: 0
sid: fb7625bfa3ad922c55833603ebc4baa8
hostname: 76.13.123.158
timestamp: 1303325358
cache: 0
session: autologout_hits|a:1:{i:0;i:1303325357;}
*************************** 88. row ***************************
uid: 0
sid: fd346efcf35b93b44b6f1a2c8b0837ae
hostname: 72.30.2.139
timestamp: 1303325669
cache: 0
session: autologout_hits|a:1:{i:0;i:1303325668;}
88 rows in set (0.00 sec)

nickrice’s picture

In the absence of a fix, is there an alternative to using autologout to force a logout?

I read something on Fourkitchens that says the solution is to disable the module :( !!!

kmasood’s picture

Try this: Update the autologout_boot function to:

function autologout_boot() {
  global $user;
  if($user->uid < 1) {
    return;
  }
  
  if ( !isset($_SESSION['autologout_hits']) ) {
    $_SESSION['autologout_hits'] = array();
  }
  $_SESSION['autologout_hits'][] = time();
}

The first few lines prevent an anonymous user from getting a session cookie.

PS: A BIG THANKS to Anthony R. from Chapter Three for providing this fix! Works in D7, try it in D6 and update the thread. Looks like it will work there as well.

jrz’s picture

The autologout_boot() function does not exist in version 6.x-4.0? I'm using D6

gcybill’s picture

Status: Active » Needs review

From what I check on its code, this D6 module has overcome this issue by

/**
 * Implementation of hook_init().
 */
function autologout_init() {
  global $user;
  if ($user->uid && _autologout_logout_role($user)) {
    // should we be enforcing on admin pages?
    if (arg(0) == 'admin' && !variable_get('autologout_enforce_admin', FALSE)) {
      return;
    }

So that we can configure the anonymous user permission to not using autologout feature. Then they will not be given server side cookie (session) and Varnish caching won't break. Anyone can confirm this?

keltic’s picture

Confirmed
autologout 6.x-2.6 varnish caching broken
autologout 6.x-4.0 varnish caching works

dandrews’s picture

Version: 6.x-4.0 » 6.x-2.6
maciej.zgadzaj’s picture

StatusFileSize
new559 bytes

Patch against version 6.x-2.x-dev (where it is still not fixed) attached.

maciej.zgadzaj’s picture

StatusFileSize
new697 bytes

Slightly better patch, not using user_is_anonymous(), as it is not available yet at this stage (in hook_boot()) when called by drush. Instead, it just replicated its code.

jrglasgow’s picture

Status: Needs review » Fixed

This patch has been committed.

@maciej.zgadzaj - thanks for the patch

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.