Redis for session_store is no longer working after upgrading rails from 5.1 to 7 even though I've updated every possible thing I can find. Redis version = 7.2.3
Updated the Gemfile to remove redis-rails and include redis-actionpack now that it comes packaged in >= Rails5.2:
gem 'redis', '~> 5.0'
gem 'redis-actionpack', "~> 5.3"
In my config/initializers/session_store.rb
Rails.application.config.session_store :redis_store,
servers: ['redis://localhost:6379/0/session'],
key: '_repubclub_session_development',
expire_after: 1.days,
signed: true,
secure: false
When I run:
redis-cli monitor
I see page requests reach Redis via output like:
1700062813.721011 [0 127.0.0.1:56195] "get" "2::a8fa0f1717f3b52bc7eb07bf006a569c3b9b2df87d70c93c5b2e500eea8ee53d"
1700062813.721201 [0 127.0.0.1:56195] "get" "dAmCGwLx3ebmdgLw96uWZnWO1agkR7DVtG1BzI5G8BxKoKEqmKuq+ZFzXIHL6w6dw2iERbwstVnmvrxVpDKcSEXmrDxZJs4u3zefOxz3/tr0uhtkUJlgLTtLHVEVveOo2XGfnoogMz1LkwOnKlinF4zVgRpGxqPZa3s5mxbwAQVQAQpnGqd8EHc5uYh6v0I3Evf2qXe0Dgw=--RTUjmnuEhMUDjlaz--ANyGuVkg015jrcKfYrwBNw=="
1700062813.768143 [0 127.0.0.1:56195] "setex" "2::ff56f6c452380a5887983d14c24c5d9673483a68e7ff1ee0945227e22fce9a03" "86400" "\x04\b{\aI\"\x0blocale\x06:\x06EF\"\aenI\"\x10_csrf_token\x06;\x00FI\"0-9bP3MWCLQfS_uX1BrCpQ9cDiyzEpTaRfz_uTSi7zpg\x06;\x00F"
Yet no flash messages are displayed and any put/post requests lead to an "ActionController::InvalidAuthenticityToken: Can't verify CSRF token authenticity" error shown below:
Started POST "/sessions" for ::1 at 2023-11-15 11:22:46 -0500
ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by SessionsController#create as HTML
Parameters: {"authenticity_token"=>"[FILTERED]", "session"=>{"cellphone"=>"", "password"=>"[FILTERED]"}}
Can't verify CSRF token authenticity.
Completed 500 Internal Server Error in 8ms (ActiveRecord: 0.0ms | Allocations: 3845)
When I swap back to using Rails' cookie_store, it works again and I receive flash messages and authentication as appropriate.