mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove key from session by using session.delete (#31685)
* Remove key from session by using session.delete You are not deleting a key from session when you assign nil to that key. * Update guides on how to destroy a user session In this commit, the user id is removed from session and controller's variables related to the user are nullified. [Rafael Mendonça França + Rafael Barbolo]
This commit is contained in:
parent
cde7c30781
commit
80cbf19453
1 changed files with 3 additions and 1 deletions
|
@ -457,7 +457,9 @@ class LoginsController < ApplicationController
|
|||
# "Delete" a login, aka "log the user out"
|
||||
def destroy
|
||||
# Remove the user id from the session
|
||||
@_current_user = session[:current_user_id] = nil
|
||||
session.delete(:current_user_id)
|
||||
# Clear the memoized current user
|
||||
@_current_user = nil
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue