【发布时间】:2015-11-15 19:45:29
【问题描述】:
在应用程序内导航和重定向都很好,它只是在浏览器刷新时用户必须重新登录。我只希望会话在浏览器关闭而不是刷新时过期..
我的 session_store.rb
Rails.application.config.session_store :cookie_store, key:
'_workspace_session'
我的会话控制器新建和创建操作:
def new
end
def create
merchant = Merchant.find_by(email: params[:email])
if merchant && merchant.authenticate(params[:password])
session[:merchant_id] = merchant.id
log_in(merchant)
flash[:success] = "You were logged in successfully"
redirect_to merchant_path(merchant.id)
else
flash.now[:danger] = "Snap! either your email or password is
incorrect. Try again"
render 'new'
end
end
【问题讨论】:
标签: ruby-on-rails session authentication