Rails session[:user_id] wont destroy
<p>Im new to Rails and having troubles trying to destroy the user session. 
My session controller looks like this</p>

<pre><code>class SessionsController &lt; ApplicationController
    def new
    end

    def create
        name = params[:name]
        password = params[:password]

        user = User.authenticate(name, password)

        if user.nil?
             render json: {isLogin: false}
        else
             session[:user_id] = user.id
             render json: {isLogin: true}
        end
    end

    def destroy
        session[:user_id] = nil
        puts session[:user_id]  # Nothing gets printed to the console here
        render json: {isLogin: false}
    end 
end
</code></pre>

<p>When I call 'sessions/destroy' and try to destroy the session, nothing gets printed at 'puts session[:user_id]' line. So I know for sure that the session is nil at that point. But the problem is that I can still access the session like this from a different controller even after I destroy the session for that user.</p>

<pre><code>class LessonsController &lt; ApplicationController

    def getLesson
        userId = session[:user_id]
        # do stuff
    end

end
</code></pre>

<p>Why is this happening? and how can I fix this?.</p>