You are here

function hook_authcache_cookie_alter in Authenticated User Page Caching (Authcache) 7.2

Modify information about cookies set by other modules.

In this example the simple nocache-cookie is replaced with a a HMAC bound to the session. Note that for this example to be effective it is necessary to implement a corresponding validation function suitable for the caching backend in place. Point the variable authcache_builtin_nocache_get to the name of an appropriate implementation when the default builtin cache backend is used.

$conf['authcache_builtin_nocache_get'] = 'my_nocache_get';

See also

hook_authcache_cookie()

authcache_fix_cookies()

_authcacheinc_default_nocache_get()

1 function implements hook_authcache_cookie_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

authcache_test_authcache_cookie_alter in tests/authcache_test.module
Implements hook_authcache_cookie_alter().
1 invocation of hook_authcache_cookie_alter()
authcache_fix_cookies in ./authcache.module
Add and remove cookies to the browser session as required.

File

./authcache.api.php, line 228
Authcache API documentation.

Code

function hook_authcache_cookie_alter(&$cookies, $account) {
  global $user;
  if (!empty($cookies['nocache']['present'])) {
    if ($user->uid) {
      $hmac = drupal_hmac_base64('nocache', session_id() . variable_get('my_nocache_auth_key'));
    }
    else {
      $hmac = drupal_hmac_base64('nocache', ip_address() . variable_get('my_nocache_auth_key'));
    }
    $cookies['nocache']['value'] = $hmac;
  }
}