Users take sessions of other users when sessions are stored in memcached (Rails)

后端 未结 5 2168
眼角桃花
眼角桃花 2020-12-14 10:30

I have a very weird problem, when storing my session in Memcached. From time to time some users takes the session of others. E.g. John, becomes logged in as Maria, Maria as

5条回答
  •  自闭症患者
    2020-12-14 10:54

    I never ran into such a problem before, I just can't imagine that it's even happening. This is my conf:

    require 'memcache'
    
    memcache_options = {
      :c_threshold => 10_000,
      :compression => true,
      :debug => false,
      :namespace => "app-me",
      :readonly => false,
      :urlencode => false
    }
    memcache_servers = [ "#{MEMCACHED_HOST}:#{MEMCACHED_PORT}" ]
    
    CACHE = MemCache.new memcache_options
    
    CACHE.servers = memcache_servers
    ActionController::Base.session_options[:expires] = 1800
    ActionController::Base.session_options[:cache] = CACHE
    
    # Inside the Rails initializer
    config.action_controller.session_store = :mem_cache_store
    

提交回复
热议问题