When Discourse is hosted from a subfolder (e.g. /forum) it seems that the cookie is still set to the root folder /.
To me this sounds like a potential security issue. For example, if a forum is hosted in /forum and a WordPress blog is hosted in /blog, the cookie with Discourse session is sent also to the WordPress site.
This should be pretty easy to fix by changing config/initializer/100-session_store.rb from
To my understanding this change shouldn’t invalidate existing sessions, because cookies for root folder / work also for subdirectory /forum. So the migration path should be ok.
Does this make sense? I could make a PR if you think this makes sense.
Note: This won’t work for serving multiple Discourse instances from different folders on the same domain. You need to use different subdomains so that each site can have different cookies.
So with this change you could remove that note. There’s no need for different subdomain if the cookies are scoped by the path. Or are there any other reasons why one couldn’t host two Discourse instances from different folders?
I tested the change and it’s safe. Sessions aren’t invalidated. I committed the change today.
Serving multiple Discourse instances from different paths on the same domain will most likely work now, but note that the instances can’t be served from one multisite setup. Multisite is still keyed off of domain, not path.