function authcache_user_login in Authenticated User Page Caching (Authcache) 7
Implements hook_user().
2 calls to authcache_user_login()
- authcache_admin_config_submit in ./
authcache.admin.inc - Authcache config form submit
- authcache_enable in ./
authcache.install - Implements hook_enable().
File
- ./
authcache.module, line 181 - Authenticated User Page Caching (and anonymous users, too!)
Code
function authcache_user_login(&$edit_ignored, $account) {
global $_authcache_is_cacheable;
// Cookie expiration
$expires = ini_get('session.cookie_lifetime');
$expires = !empty($expires) && is_numeric($expires) ? REQUEST_TIME + (int) $expires : 0;
//TODO:d7 - does it make sense to disable caching for uid == 1 ?
//$no_cache = (isset($account->uid) && ($account->uid == 1 || !isset($_COOKIE['has_js'])));
$no_cache = !isset($_COOKIE['has_js']);
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 (_authcache_debug_access()) {
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');
}