Check if any user is logged in or not

I need to check if any user has logged-in or not.
I am referring to the code at, but it does not seem to work fine for me.

Backendless.LocalCache.get(“current-user”) is returning undefined and not null.

Can you please let me know how to check it? How do I know if I am using persistent login or not.

If you set the stayLoggedIn argument to true, then you’re using persistent login. Do you do that in your code?

Yes, Its TRUE in the code. but still that does not work. The value is returend as undefined instead of null.

The value is returned as undefined instead of null.

Returned from what method?

As mentioned in intial comment, Backendless.LocalCache.get(“current-user”) code returns undefined.

try the first method, it should also work for you:

var currentUser = Backendless.UserService.getCurrentUser();

Thanks for response. Let me play around more. I was confused as I was using persistent storage and it returned “undefined”. Will try further and let you know.

It works. But please have the document corrected with the other method.

If this works, why we need another method?

It has been fixed in the docs.