CometChat.login(authToken) with the value from the response.
Nothing else changes. The REST API key stays on the server, the browser never builds or stores a token itself, and there is no separate token endpoint to secure.
Backend: add the token to your login response
Inside your existing PHP login handler, after your own credential check has succeeded:Frontend: log in with the token from the response
In the code that already submits your login form and handles the response:onLoggedIn() runs in both paths, so chat keeps working after a reload: getLoggedinUser() returns the cached user and no new token is needed. Code placed only in the login path would run once and never again.Call
CometChat.logout() from your app’s own logout and account-switch code, so the cached SDK user never outlives your app’s login. To cut off a user’s CometChat access from the server, for example after a password reset, revoke their tokens with Delete Auth Token or Flush Auth Tokens.