diff --git a/masquerade.module b/masquerade.module index 1a9841e..898ef18 100644 --- a/masquerade.module +++ b/masquerade.module @@ -668,7 +668,18 @@ function masquerade_switch_user($uid) { watchdog('masquerade', 'User %user now masquerading as %masq_as.', array('%user' => $user->name, '%masq_as' => $new_user->name ? $new_user->name : variable_get('anonymous', 'Anonymous')), WATCHDOG_INFO); drupal_set_message(t('You are now masquerading as !masq_as.', array('!masq_as' => theme('username', $new_user)))); $user->masquerading = $new_user->uid; + + // Allow masquerade to work with bakery by deleting cookies and then setting a cookie for the new user. + if (module_exists('bakery')) { + _bakery_eat_cookie(); + // Destroy session cookie. + _bakery_eat_cookie(session_name()); + } $user = $new_user; + + if (module_exists('bakery')) { + _bakery_bake_chocolatechip_cookie($user->name, $user->mail, url("user/$user->uid/edit", array('absolute' => TRUE))); + } return TRUE; }