logging:session或cookie(带rails)?

时间:2015-01-13 10:29:42

标签: ruby-on-rails session cookies

如果我使用签名的cookie来保存" session_token"有32个randomed字符,为什么继续使用session?

为例:

def current_user
  return nil unless authentication_token = cookies.signed[:authentication_token]
  @_current_user ||= User.find_by_authentication_token(authentication_token)
end


def current_user=(user)
  return cookies.delete(:authentication_token) if user.nil?
  cookies.signed.permanent[:authentication_token] = user.authentication_token
end

使用会话有什么好处?

0 个答案:

没有答案