我通过此行代码设置响应Cookie
module Users
class SessionsController < Devise::SessionsController
skip_before_action :authenticate_user
skip_before_action :verify_authenticity_token
skip_before_action :verify_signed_out_user # Skip this action from super class
.....
def handle_login(response)
ApplicationRecord.transaction do
// Verify user
// Issues new token
auth_token = issue_auth_token user
# Delete current user auth token and create new one
session.delete(:current_authentication_token)
session[:current_authentication_token] = auth_token.authentication_token
cookies[:current_authentication_token] = {:value => auth_token.authentication_token, :expires => 1.month.from_now, :domain => :all}
redirect_to users_homes_path
end
end
end
它在localhost上运行良好,但是当我将项目部署到ec2时,键为current_authentication_token
的cookie没有保存。