Module Devise::Models::Rememberable
In: lib/devise/models/rememberable.rb

Rememberable manages generating and clearing token for remember the user from a saved cookie. Rememberable also has utility methods for dealing with serializing the user into the cookie and back from the cookie, trying to lookup the record based on the saved information. You probably wouldn‘t use rememberable methods directly, they are used mostly internally for handling the remember token.

Options

Rememberable adds the following options in devise_for:

  * +remember_for+: the time you want the user will be remembered without
    asking for credentials. After this time the user will be blocked and
    will have to enter his credentials again. This configuration is also
    used to calculate the expires time for the cookie created to remember
    the user. By default remember_for is 2.weeks.

  * +remember_across_browsers+: if a valid remember token can be re-used
    between multiple browsers. By default remember_across_browsers is true
    and cannot be turned off if you are using password salt instead of remember
    token.

  * +extend_remember_period+: if true, extends the user's remember period
    when remembered via cookie. False by default.

  * +cookie_options+: configuration options passed to the created cookie.

Examples

  User.find(1).remember_me!  # regenerating the token
  User.find(1).forget_me!    # clearing the token

  # generating info to put into cookies
  User.serialize_into_cookie(user)

  # lookup the user based on the incoming cookie information
  User.serialize_from_cookie(cookie_string)

Methods

Classes and Modules

Module Devise::Models::Rememberable::ClassMethods

Attributes

extend_remember_period  [RW] 
remember_me  [RW] 

Public Instance methods

If the record is persisted, remove the remember token (but only if it exists), and save the record without validations.

Remember token should be expired if expiration time not overpass now.

Remember token expires at created time + remember_for configuration

Generate a new remember token and save the record without validations unless remember_across_browsers is true and the user already has a valid token.

[Validate]