Module: Authlogic::Session::Cookies::Config

Defined in:
lib/authlogic/session/cookies.rb

Overview

Configuration for the cookie feature set.

Instance Method Summary collapse

Instance Method Details

The name of the cookie or the key in the cookies hash. Be sure and use a unique name. If you have multiple sessions and they use the same cookie it will cause problems. Also, if a id is set it will be inserted into the beginning of the string. Example:

session = UserSession.new
session.cookie_key => "user_credentials"

session = UserSession.new(:super_high_secret)
session.cookie_key => "super_high_secret_user_credentials"
  • Default: “#Authlogic::Session::Cookies::Config.klass_nameklass_name.underscore_credentials”

  • Accepts: String



31
32
33
# File 'lib/authlogic/session/cookies.rb', line 31

def cookie_key(value = nil)
  rw_config(:cookie_key, value, "#{klass_name.underscore}_credentials")
end

#httponly(value = nil) ⇒ Object Also known as: httponly=

Should the cookie be set as httponly? If true, the cookie will not be accessible from javascript

  • Default: false

  • Accepts: Boolean



69
70
71
# File 'lib/authlogic/session/cookies.rb', line 69

def httponly(value = nil)
  rw_config(:httponly, value, false)
end

#remember_me(value = nil) ⇒ Object Also known as: remember_me=

If sessions should be remembered by default or not.

  • Default: false

  • Accepts: Boolean



40
41
42
# File 'lib/authlogic/session/cookies.rb', line 40

def remember_me(value = nil)
  rw_config(:remember_me, value, false)
end

#remember_me_for(value = nil) ⇒ Object Also known as: remember_me_for=

The length of time until the cookie expires.

  • Default: 3.months

  • Accepts: Integer, length of time in seconds, such as 60 or 3.months



49
50
51
# File 'lib/authlogic/session/cookies.rb', line 49

def remember_me_for(value = nil)
  rw_config(:remember_me_for, value, 3.months)
end

#secure(value = nil) ⇒ Object Also known as: secure=

Should the cookie be set as secure? If true, the cookie will only be sent over SSL connections

  • Default: false

  • Accepts: Boolean



59
60
61
# File 'lib/authlogic/session/cookies.rb', line 59

def secure(value = nil)
  rw_config(:secure, value, false)
end

Should the cookie be signed? If the controller adapter supports it, this is a measure against cookie tampering.



76
77
78
79
80
81
# File 'lib/authlogic/session/cookies.rb', line 76

def sign_cookie(value = nil)
  if value && !controller.cookies.respond_to?(:signed)
    raise "Signed cookies not supported with #{controller.class}!"
  end
  rw_config(:sign_cookie, value, false)
end