Help: session is deleted, but after the view is rendered

Scenario:

user is logged in, they click the logout button, which fires the action
method Sessions#destroy and the view. The problem i’m having is that
even tho the session is deleted, the first go round it still displays
logged in. If you refresh it then says not logged in. I am not sure how
to even begin debugging this. thanks!

Controller:

class SessionsController < ApplicationController

def destroy
session[:user_id] = @current_id = nil
end
end

Main layout:


<% if @current_user %>
Logged in as: <%= @current_user.login %>
<%= link_to ‘Logout’, session_path, :method => :delete %>
<% else %>
Not logged in.
<%= link_to ‘Login’, new_session_path %>
<% end %>

On Dec 21, 10:43 pm, Merrick Johnson <rails-mailing-l…@andreas-
s.net> wrote:

Scenario:

user is logged in, they click the logout button, which fires the action
method Sessions#destroy and the view. The problem i’m having is that
even tho the session is deleted, the first go round it still displays
logged in. If you refresh it then says not logged in. I am not sure how
to even begin debugging this. thanks!

Controller:

class SessionsController < ApplicationController

def destroy
session[:user_id] = @current_id = nil

Don’t you want to nil out @current_user rather than @current_id ?

Fred

Don’t you want to nil out @current_user rather than @current_id ?

Fred

good call fred! thanks pal, worked like a charm.