Simple code to expire Drupal cookie?
Posted
by user310594
on Stack Overflow
See other posts from Stack Overflow
or by user310594
Published on 2010-06-03T01:10:23Z
Indexed on
2010/06/03
1:14 UTC
Read the original article
Hit count: 367
With a single click this simple script will do a multi-logout of:
Moodle
Elgg
2 MyBB's and
(not) Drupal.
<?php
setcookie( 'Elgg', '', -3600, '/', '.domain.com', false, false);
setcookie( 'http_auth_ext_complete', '1', -3600, '/d/', '.domain.com', false, false);
// setcookie( 'http_auth_ext_complete', '1', -3600, '/d/', 'domain.com', false, false);
setcookie( 'mybbuser', '', -3600, '/', '.domain.com', false, false);
setcookie( 'mybbuser', '', -3600, '/bb/', '.domain.com', false, false);
// unset all 3 Moodle cookies, the lazy way
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
}
?>
This works on four sites but the Drupal cookie won't quit. How can I do the same with Drupal?
Note: Drupal uses 'host' instead of 'domain', neither with or without the '.' works so far.
Thank you.
© Stack Overflow or respective owner