Rails Session Store + Redis: Can I set TTLS in redis without setting expiration on sessions?

394 Views Asked by At

Is there a way to add a TTL to sessions stored in Redis by Active Record Session Store without cookies getting an expiration date to match? I don't want my users' cookies stored and my understanding is that if cookies have an expiration, browsers will try to store them on disk. I'm trying to avoid the risk of session re-use if possible.

1

There are 1 best solutions below

1
titan2gman On

You can try to set expires_in in session store configuration (config/initializers/session_store.rb):

App::Application.config.session_store :redis_store,
  :servers =>{
    :host => ENV["REDIS_HOST"],
    :port => ENV["REDIS_PORT"],
  },
  :expires_in => 30.minutes