我有一个外部非Drupal网站members.example.com,如果受众成员登录该网站,则会设置Cookie。它设置了Drupal站点可见的cookie:
$ _ COOKIE ['name'] ='John Smith';
我想知道members.example.com登录用户可以访问Drupal网站www.example.com上的优质内容。我还想在网站的眉毛部分以名字命名登录成员。
问题是,在登录非Drupal站点members.example.com并返回到Drupal站点www.example.com之后,Drupal仍在缓存大量内容并且无法识别该用户现在设置了$ _COOKIE ['name']。
我有:
将settings.php中的cookie域设置为“example.com”
试图破坏匿名Drupal用户的缓存,这些用户也拥有这个cookie:
/**
* Implements hook_init()
*/
function caplogin_init() {
// Check for cookie if it's set to 'loggedout':
if (isset($_COOKIE['name'])) {
if (strpos($_COOKIE['name'],'loggedout') !== FALSE) {
// Log them out on the www site too:
setcookie('name', '', 1, '/', '.example.com');
global $user;
if ($user->uid > 0) {
user_logout();
}
$reason = 'Members server logout.';
_caplogin_no_cache($reason);
drupal_set_message(t('You have been logged out of the site. Thanks for visiting!'));
}
else {
$reason = 'Member logged in internal server.';
_caplogin_no_cache($reason);
}
}
}
和...
function _caplogin_no_cache($reason) {
if (!$reason) {
$reason = 'no-cache called by site functionality.';
}
drupal_add_http_header('X-DRCC-No-Cache-Reason', $reason);
drupal_add_http_header('Pragma', 'no-cache');
drupal_add_http_header('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
drupal_add_http_header('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
drupal_add_http_header('Expires', 'Sat, 02 Jan 1971 00:00:00 GMT');
}
我还安装了Devel模块,并且(用于测试)选中了ON复选框,用于在每个页面加载时重建主题缓存。没有运气。
如果你添加一个伪造的查询字符串,它就会破坏缓存,例如: http://www.example.com/?sdjaSDH
但客户端需要Drupal识别出用户已登录外部members.example.com网站的功能。
我还能尝试什么?
答案 0 :(得分:1)
这样做
$GLOBALS['conf']['cache'] = FALSE;
帮忙?
您可能需要将此代码添加到hook_boot()或hook_init()以及您想要的一些开关。