ruby-on-railsclearance

How to set Session length for a User in Clearance?


How do I kill the session cookie for a user that closes their browser and or a day passes in Clearance?

I do see the following config vars, but I believe the cookie expiration is for the general cookies, not for the session cookie?

Clearance.configure do |config|
  config.cookie_domain = ".trajectsku.com"
  config.cookie_expiration = lambda { |cookies| 1.year.from_now.utc }
end

Solution

  • The clearance docs do explain that cookie expiration is what you are after. If you want the cookie to expire with the browser session, you should set the lambda to return nil like so:

    Clearance.configure do |config|
      config.cookie_domain = ".trajectsku.com"
      config.cookie_expiration = lambda { |_cookies| nil }
    end