4

We are facing a weird problem where-in few keys/cookies are getting deleted/missing from the session in our rails 3.2 app (staging environment) which has the following cache settings/configuration. The session store is cookie store and has been configured as follows:

    Appsrv::Application.config.session_store :cookie_store, {
      :key =>           'SSID',
      :path =>          '/',
      :domain =>        APP_CONFIG['site_url'].sub(/^https?:\/\//, ""),
      :expire_after =>  30.minutes,
      :secret =>        's23asdfe443534afdgstreggv234324we434',
      :secure =>        false # cookie not for just https
   }

The rails cache store is a memcache store and we use dalli gem to integrate rails and memcache.

The following configuration has been added to different .rb files:

    config.cache_store = :dalli_store, 'staging01:11211', 'staging02:11211',  'staging03:11211', 'staging04:11211'
                     {:namespace => "appsrv", :expires_in => 86400, :compression => true}  
    config.action_controller.perform_caching = true

The flow where this scenario of missing cookies happens is a bit complicated though. The scenario where this happens is as follows:

  1. User starts a session by visiting a page on Appsrv(rails 3.2 app, some variables identifying user transaction are set in session at this time)
  2. Goto external website for auth.
  3. External website redirects to a Java App server after successful auth.
  4. Java App server records the auth and redirects back to Appsrv.
  5. But after this redirection the session variables set in step 1 are gone.

Some weird findings: Things work perfectly in the development environment where the only difference is:

    config.action_controller.perform_caching = false

If we have the same setting in staging "config.action_controller.perform_caching=false" then staging also works fine. Even with "config.action_controller.perform_caching" set to false, caching actually happens properly in controllers and models.

So the questions are: 1. Why do the session cookies get deleted when the config.action_controller.perform_caching is set to true? 2. What is the significance of config.action_controller.perform_caching configuration if setting it to false also allows cache to happen properly?

0 Answers0