login
This page provides examples of login operations.
Prerequisites
See the Sign Up for more information.
Dependent Libraries
Only need reference two Javascript Libraries in HTML:
The first line reference the client function library. This's a dynamic library includes many dynamic components and CDN resources, so don't save to local. The second line is using third-party socket library from CDN.
Create a client instance
If you connect multiple servers at the same time, you can create multiple client instances. Connect a server, Load authentication module, Provide offline login codes and method, logout codes and method, multi-server login, automatic login, user cache and other functions of authentication. If you don't need these features, you should not execute this line of code.
Log In code
Use local cache to automatically login can be written as follow:
Logout code
Get user example
Above codes are equivalent to:
Catch Log In's exception
Use try...catch statement marks a block of statements to try, and specifies a response, should an exception be thrown.
Asynchronous catch
Synchronous catch
Complete codes of Log In
Last updated