Proposed resolution
Greetings.
I have a suggestion for improvement for this function.
Soon after the session_destroy (), could be placed a drupal_set_message () to warn the user of the reason for the logout.
Would be as follows:
function user_logout($message = '', $status = 'warning') {
global $user;
watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
module_invoke_all('user_logout', $user);
// Destroy the current session, and reset $user to the anonymous user.
session_destroy();
// Start
// Sends a message to the user if you have a need to warn you
if(!empty($message)){
drupal_set_message($message, $status);
}
// End
drupal_goto();
}
Why is this suggestion?
When I'm using hook_user_login and for some reason need to kill the session user can not I put after user_logout drupal_set_message () why there is a drupal_goto () and also no point in putting before why there is a session.destroy () which kills with the entire session.
The only way I saw to solve this is after putting session.destroy ().
[]'s
Comments
Comment #1
superspring commentedSince user_logout is mostly called by callbacks the parameters given above would not be called most often.
This patch hangs on to all drupal_set_message calls after the session has been destroyed thus allowing the logout hooks to add a message to this and will remain persistant after the session is destroyed.
Comment #3
superspring commentedHmmm, not too sure what the Poll cache has to do with this for why it failed testing.
Since this is a functional change, here is a D8 patch too.
Comment #4
superspring commented#1: user_logout_messages-1433124-1.patch queued for re-testing.
Comment #6
superspring commentedComment #7
superspring commentedComment #9
superspring commentedSame idea with a different implementation.
Comment #11
superspring commented#9: user_logout_messages-1433124-4.patch queued for re-testing.
Comment #13
superspring commentedNow setting cookies properly.
Comment #15
superspring commented#13: user_logout_messages-1433124-5.patch queued for re-testing.
Comment #18
dcam commentedClosed the duplicate issue that was created for 7.x, #2345007: Suggested improvements in user_logout(). I'm guessing the creator of that issue would like the feature to be backported, so I'm tagging it. I don't know if it can be backported or not. The other issue does have a 7.x patch.
Comment #32
smustgrave commentedThank you for sharing your idea for improving Drupal.
We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #33
smustgrave commentedSince there's been no follow up in 3+ months going to close this one out, but if still a desired feature please re-open.
Thanks!