How to retrieve logged in user ID from front-end JavaScript

On Bubble JavaScript, I would like to get the authenticated user ID from front end - either via cookies or any other way. Is there any way to achieve this?

My larger goal was to get authentication credentials from cookies but it seems Bubble has kept it as HttpOnly for security reasons (which makes sense).

1 Like

Any Bubble developers who work at Bubble out here? I am interested to learn as well. From our research, it seems like there is no way to get logged in userID from front-end JS.

I think with the help of the Bubble plugin you can do -

Use code - properties.attachto.get("_id")to get the user id in the Bubble plugin editor.

Ankur@ Nocodetalks
Looking for a Bubble Coach? Checkout here

1 Like

Thanks @ankur1
Is it possible to do without a Bubble plugin? Within the app, is it possible to do?

DATA CALL: current users’ unique ID

1 Like

Thanks @GH5T
On data call, current user’s unique id works but how to pass that user’s unique id from server to JavaScript later?

Well, assuming you’re using a JS snipper in the front-end somewhere, you’d call:
"Do a Search for > User's (constraint: created by = current user) unique ID"