Replies: 1 comment 2 replies
-
What part of |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a Rails 7 app using Devise for authentication, that signs up a new user on the www.my-site.com subdomain and redirects them to the actual app after signup at dashboard.my-site.com. Also, my multi-tenant app gives subdomains to each user, so user-10.my-site.com, which must have it's own separate cookies too.
I wrote custom middleware to solve this problem (mostly outlined in this answer), but it turns out that this doesn't appear to work anymore, since at least Rails 5.
You can try to set the cookie key with
env['rack.session.options'][:key] = "my-dynamic-key"
orRails.application.config.session_store :cookie_store, key: "_myapp_session", domain: custom_domain(host), tld_length: 2
- but the actually cookie key on the client never changes. From what I can tell, it's no longer possible to set cookies dynamically using middleware with Rails. The cookie attributes (key, domain, etc.) always remain as the defaults provided when the application begins.There are plenty of answers on the internet that reference this old way of dynamically setting cookies. But it just doesn't work. I created a new Rails project to ensure that it wasn't something in my project that was breaking it - and alas, the custom middleware didn't work there either.
I've spent the last several days trying to understand why it doesn't work anymore, and what a potential resolution might be, but I have no answers. Does anyone have any ideas?
Beta Was this translation helpful? Give feedback.
All reactions