Suggested improvements in user_logout()

Created on 8 February 2012, about 13 years ago
Updated 7 April 2025, 15 days ago

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

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

user.module

Created by

πŸ‡§πŸ‡·Brazil Ferrari

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank 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!

Production build 0.71.5 2024