function authcache_user in Authenticated User Page Caching (Authcache) 6
Implements hook_user().
2 calls to authcache_user()
- authcache_admin_config_submit in ./
authcache.admin.inc - Authcache config form submit
- authcache_enable in ./
authcache.install - Implements hook_enable().
File
- ./
authcache.module, line 186 - Authenticated User Page Caching (and anonymous users, too!)
Code
function authcache_user($op, &$edit, &$account, $category = NULL) {
global $is_page_authcache;
// Cookie expiration
$expires = ini_get('session.cookie_lifetime');
$expires = !empty($expires) && is_numeric($expires) ? time() + (int) $expires : 0;
$no_cache = isset($account->uid) && ($account->uid == 1 || !isset($_COOKIE['has_js']));
switch ($op) {
case 'load':
break;
case 'update':
break;
case 'insert':
break;
case 'register':
break;
case 'login':
if ($no_cache) {
setcookie('nocache', 1, $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
else {
setcookie('authcache', _authcache_key($account), $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
// Authcache debugging
if (in_array($account->name, variable_get('authcache_debug_users', array()))) {
setcookie('authcache_debug', 1, $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
// Required to differentiate from anonymous users
setcookie('drupal_user', $account->name, $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
setcookie('drupal_uid', $account->uid, $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
break;
case 'logout':
// Note: include same cookie deletion in ajax/authcache.module
setcookie('drupal_user', "", time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
setcookie('drupal_uid', "", time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
setcookie('authcache', "", time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
if (isset($_COOKIE['nocache'])) {
setcookie('nocache', "", time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
if (isset($_COOKIE['authcache_debug'])) {
setcookie('authcache_debug', "", time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
foreach ($_COOKIE as $key => $value) {
if (substr($key, 0, 3) == 'nid') {
setcookie($key, "", time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
}
break;
default:
break;
}
}