浏览器刷新后Rails会话不会持久化

时间:2015-08-21 18:54:30

标签: ruby-on-rails session authentication

在应用程序内导航并重新定向都很好,只是在浏览器刷新时用户必须重新登录。我只希望会话在浏览器关闭时过期而不是刷新...

我的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

0 个答案:

没有答案