The user, Young_Nam, is experiencing an issue with multiple Discourse instances. When visiting the second instance, they are signed out of the first instance. This occurs when running two development instances or a development instance and a Docker instance. Young_Nam is not trying to use one account for both instances, but rather separate accounts for each instance.
Stephen asks if these instances are for production or development purposes. Young_Nam clarifies that they are trying to run one development instance and one personal instance.
pfaffman resolves the issue by suggesting that the instances need to have different host names to avoid using the same cookies. Young_Nam confirms that using different host names or different browsers resolves the issue.
To avoid cookie collision, Young_Nam suggests using different Chrome instances, 127.0.0.1 instead of localhost, and possibly using an alias. Stephen recommends using two hostfile entries, allowing the instances to share the same IP without suffering from cookie collision.
EDIT after resolved: This happened when I open the second Discourse instance, not when I start the server.
I have two Discourse directories. I followed the following guide to install it.:
So, the first one, say,
cd ~/discourse
bundle exec rails server --binding=0.0.0.0
is running okay, I can sign in, create my topics, etc.
Then I run another Dicsourse instance after changing the config/database.yml to use different ‘database’ name and run it on different port:
cd ~/discourse2
bundle exec rails server -p <different-port> --binding=0.0.0.0
It does create those databases additionally. And it runs, sure. But when I visit the first instance that’s been running and refresh, I’m signed out from it. I can log in into the second instance, and start my thing there. And when I log into my first instance, it signs me out from the second instance.
And now I’ve tried running Discourse on Docker, it runs, but when I visit localhost and I get the “Register page”, I’m logged out from the running Discourse.
I’m not trying to use one account for two instances.
How do I keep each account signed-in on its own Discourse instance? (Account ‘foo’ on ‘discourse’ and account ‘bar’ on ‘discourse-2’ instance)
Correct me if I’m wrong, I’m thinking of Discourse running from a Docker container to be the production instances (or purpose?) and the instances that run from the discourse/discourserepo to be development instance.
I tried running two development instances first, then failed (visiting or starting one instance logs me out from currently running one, but I can log in again which would log me out from the newly started/visited instance if I’m already logged in).
Then tried with an instance running in development instance, and another from Docker, and the same thing happens.
So, I need at least one ‘development purpose’ Discourse to run. And I need one instance for my own personal use. Sure, I could host the personal one of ‘production instance’ on a cloud service, but that would cost me (little amount of) money. Even then, I’m just confused why this is the case when I’m expecting it to just work.
I was able to have each account on each instance not interfere each other’s login by using different browser, or different ‘account bounded chrome instance’ (or something).