RoR Security Guide指出,您應該「使用reset_session方法來對付會話固定時,」發出一個新的會話標識符並聲明成功登錄後無效的舊會話標識符「。帶有Authlogic和調用reset_session的Rails 3
使用Authlogic時,我一直無法找到調用reset_session的任何指導。是否僅僅是將方法包含在控制器方法中的情況(如下所示)?
我只關心導致Authlogic問題,因爲我可以在調用reset_session之前在會話散列中看到user_credentials和user_credentials_id鍵和值。
class UserSessionsController < ApplicationController
def create
@user_session = current_client.user_sessions.new(params[:user_session])
if @user_session.save
reset_session
flash[:success] = I18n.t(:msg_login_success)
redirect_back_or_default application_root_path
else
render :action => :new
end
end
成功登錄後,依然表現正如我們推薦的reset_session什麼是加入'「CURRENT_USER」點=> {}'到temp_session? – mikong
這樣做是爲了清空會話中「current_user」鍵的內容 –