module Authlogic::Session::Cookies::InstanceMethods

The methods available for an Authlogic::Session::Base object that make up the cookie feature set.

Public Instance Methods

credentials=(value) click to toggle source

Allows you to set the #remember_me option when passing credentials.

Calls superclass method
# File lib/authlogic/session/cookies.rb, line 82
def credentials=(value)
  super
  values = value.is_a?(Array) ? value : [value]
  case values.first
  when Hash
    self.remember_me = values.first.with_indifferent_access[:remember_me] if values.first.with_indifferent_access.key?(:remember_me)
  else
    r = values.find { |value| value.is_a?(TrueClass) || value.is_a?(FalseClass) }
    self.remember_me = r if !r.nil?
  end
end
httponly() click to toggle source

If the cookie should be marked as httponly (not accessable via javascript)

# File lib/authlogic/session/cookies.rb, line 145
def httponly
  return @httponly if defined?(@httponly)
  @httponly = self.class.httponly
end
httponly=(value) click to toggle source

Accepts a boolean as to whether the cookie should be marked as httponly. If true, the cookie will not be accessable from javascript

# File lib/authlogic/session/cookies.rb, line 151
def httponly=(value)
  @httponly = value
end
httponly?() click to toggle source

See httponly

# File lib/authlogic/session/cookies.rb, line 156
def httponly?
  httponly == true || httponly == "true" || httponly == "1"
end
remember_me() click to toggle source

Is the cookie going to expire after the session is over, or will it stick around?

# File lib/authlogic/session/cookies.rb, line 95
def remember_me
  return @remember_me if defined?(@remember_me)
  @remember_me = self.class.remember_me
end
remember_me=(value) click to toggle source

Accepts a boolean as a flag to remember the session or not. Basically to expire the cookie at the end of the session or keep it for “remember_me_until”.

# File lib/authlogic/session/cookies.rb, line 101
def remember_me=(value)
  @remember_me = value
end
remember_me?() click to toggle source

See #remember_me

# File lib/authlogic/session/cookies.rb, line 106
def remember_me?
  remember_me == true || remember_me == "true" || remember_me == "1"
end
remember_me_expired?() click to toggle source

Has the cookie expired due to current time being greater than remember_me_until.

# File lib/authlogic/session/cookies.rb, line 123
def remember_me_expired?
  return unless remember_me?
  (Time.parse(cookie_credentials[2]) < Time.now)
end
remember_me_for() click to toggle source

How long to remember the user if #remember_me is true. This is based on the class level configuration: #remember_me_for

# File lib/authlogic/session/cookies.rb, line 111
def remember_me_for
  return unless remember_me?
  self.class.remember_me_for
end
remember_me_until() click to toggle source

When to expire the cookie. See #remember_me_for configuration option to change this.

# File lib/authlogic/session/cookies.rb, line 117
def remember_me_until
  return unless remember_me?
  remember_me_for.from_now
end
secure() click to toggle source

If the cookie should be marked as secure (SSL only)

# File lib/authlogic/session/cookies.rb, line 129
def secure
  return @secure if defined?(@secure)
  @secure = self.class.secure
end
secure=(value) click to toggle source

Accepts a boolean as to whether the cookie should be marked as secure. If true the cookie will only ever be sent over an SSL connection.

# File lib/authlogic/session/cookies.rb, line 135
def secure=(value)
  @secure = value
end
secure?() click to toggle source

See secure

# File lib/authlogic/session/cookies.rb, line 140
def secure?
  secure == true || secure == "true" || secure == "1"
end

Private Instance Methods