Automatic logout?

Hello,
After being logged in with CometChat for a longer period of time we have experienced it not working any more. If we log out of our app and then log back in our app (this also means logging back into CometChat - CometChat.init ad CometChat.login …) everything works again.
We are using CometChat Pro with the JavaScript SDK, is there something that we can do to query the CometChat state and then do the necessary steps to endure it’s continuous work-ability?
Best,
Mihaela

Hello @MihaelaCazan,

The SDK stores the last logged in user in local storage. Every time a user loads your website you first have to initialize the SDK and then check what CometChat.getLoggedInUser() returns.

  1. User Object => It means that user is logged in and you can go ahead without calling the CometChat.login().

  2. null => It means there is no logged in user and you have to log in the user using CometChat.login().

Also, please note that if you clear the browser local storage then CometChat.getLoggedInUser() will return null. The storage is only cleared when you logout from CometChat. Hope this helps!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.