Share login status with other apps

In the Users service I can select an option to “share my login status with other apps”.

Can someone explain how this works?

From within one application, if I click a link to open another app, I cannot access the current user’s information (email, etc) from the newly opened app, even though the two apps share the same User table and login status (anvil.users.get_user() gives back None). Perhaps login status is not the same as login information…

What am I missing here?

Hmm, that should work! Quick check: Are those two apps hosted on the same top-level domain? If one app is foo.bar.com and the other is xyz.net, we can’t get cookies to communicate between the two…

(This is the same restriction as we have for the server-side cookie functions)

Ah, maybe that is it. I confess to not know much about these things.

My main app is https://my_main_app.anvil.app. Would I have to give the app it’s calling a subdomain?

I tried https://some_sub_domain.my_main_app.anvil.app, but Anvil wouldn’t let me use the first dot.

If they’re both on anvil.app (eg something.anvil.app and something-else.anvil.app), then it should work. (The problem I was talking about is most common if you have one of them on a custom domain and the other one on something.anvil.app)

You might want to drop us an email at support@anvil.works with the URLs and clone links of both apps

Having looked at @alcampopiano’s apps, we found that the problem is a bug in the Users service that occurs if you embed apps inside each other and switch a particular setting on and off. We’ll get it fixed.

The workaround is to re-add the Users service to each app (I was able to get @alcampopiano’s apps to work by doing this).

I can confirm that once I removed and re-added the Users service in my official apps that this indeed solved the problem. Thanks Anvil team!

1 Like