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:
Rafael Barbolo 2018-04-23 14:50:59 -03:00 committed by Rafael França
parent cde7c30781
commit 80cbf19453
1 changed files with 3 additions and 1 deletions

View File

@ -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