How do I modify the session_store initializer


(etewiah) #1

I need to make a change to the ‘config/initializers/session_store.rb’ file and I’m not too sure the best way to do this with a docker install.

I need to change it from this:

Discourse::Application.config.session_store :cookie_store, key: '_forum_session'

to this

Discourse::Application.config.session_store :cookie_store, key: '_forum_session', domain: '.klavado.com'

I need to do this so the session cookie is stored across all subdomains for my server. If there isn’t an easy way to edit the initializer file so that it does not change across updates, might there be a way to override that initializer in a plugin?


(Sam Saffron) #2

not sure but will after_initialize in a plugin take ?


(etewiah) #3

Thanks for the reply @sam. Turns out I was barking up the wrong tree anyway. I wanted a user who authenticated at one subdomain to remain logged in at any other subdomain. So it was the auth_token I needed to save differently.
I did that by creating a custom CurrentUserProvider that specifies the domain when saving the auth_token.

Still curious to know the right way to override initializers in a plugin though. I also thought the after_initialize hook might work but I wanted to be sure its the right way to do it. Even if I tried it and it seemed to work, my understanding of Rails internals isn’t great and I’m not sure what side-effects / problems that might cause.