Posted by MattParsons on February 1, 2007 at 3:06pm
Hi there,
I am integrating my own program into a Drupal install, and have log out buttons on my pages. I currently have them redirecting to a script which contains the following:
<?php
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
sess_destroy($key);
sess_destroy(session_id());
db_query("TRUNCATE TABLE cache");
header ("Location: /Home.php");
?>This doesn't appear to be cancelling the user's session however, so does anyone know what i've missed!?
Any thoughts would be great!
Thanks.
Comments
I had a custom logout in module
I did this in reponse to a menu handler 'mymodule/logout' vs. a different .php file so I was already bootstapped, etc. and in the normal drupal callback handling so not exactly like your example but this worked.
<?php
function my_user_logout() {
watchdog('user', t('Session closed for %name.', array('%name' => $user->name)));
// Destroy the current session:
session_destroy();
module_invoke_all('user', 'logout', NULL, $user);
// Load the anonymous user
$user = drupal_anonymous_user();
drupal_goto('node');
}
?>
dLd
dLd