Skip to content
Back

How to determine if a user is anonymous?

  • 0
  • Self Hosted
  • Auth
  • Apple
Aphantasia
19 Jan, 2026, 17:13

This is probably a silly question, but I have not yet found a good answer.

Is there a method to determine if the current session is anonymous aside from seeing if email, name, etc is blank?

TL;DR
To determine if a developer is anonymous, check if the email and phone fields are empty in the session object. If they are, the developer is anonymous. The closest deterministic method is based on the lack of name, email, and phone. You can use `console.log(user)` to see the specific field that represents anonymous users. Check the roles or use `account.get` which will throw an error if the user is not logged in. There is no direct method aside from checking for blank fields to determine anonymous sessions.
Bret
19 Jan, 2026, 17:20

https://appwrite.io/docs/references/cloud/server-nodejs/account#get

This method will throw an error if the user is not logged in.

Bret
19 Jan, 2026, 17:21

You can check this error to determine if the user is logged in.

Bret
19 Jan, 2026, 17:24

For anonymous users, you can check their roles.

Aphantasia
19 Jan, 2026, 17:25

That is what I thought too, but this is not erroring. The images are from a session that was created using createAnonymousSession. account.get is actually succeeding despite the fact that entry was created by the anonymous session.

Bret
19 Jan, 2026, 17:28

The error will only occur if the user is not logged in. There should be a field to represent anonymous users; you can try console.log(user) to see the specific name of that field (I forgot because I've forgotten).

Aphantasia
19 Jan, 2026, 17:32

https://appwrite.io/docs/references/cloud/models/user https://appwrite.io/docs/references/cloud/models/session

I am not seeing a field that indicates that on either one. Closest I could figure would be provider on the session object. But that doesn't seem to be doing what I thought it would.

Aphantasia
19 Jan, 2026, 17:37

Looks like based on the current version of console, they're also determining it by lack of name, email, and phone. So I guess that is the closest thing we have to a deterministic method. https://github.com/appwrite/console/blob/9c8b88e70ff5b7ac6e44130f58839660aab4c48e/src/routes/(console)/project-%5Bregion%5D-%5Bproject%5D/auth/user-%5Buser%5D/dangerZone.svelte#L47

Axistro
19 Jan, 2026, 17:52

Just check if both phone and the email feild is empty in session object. If yes Annonymous 😐

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more