# wx.checkSession(Object object)
with Promise style call: Supported
Mini Program plugin: Not supported
Check whether the login state is expired. adopt wx.login The user login state obtained by interface has certain timeliness. The longer the user does not use the Mini Program, the more likely the user login state will fail. On the other hand, if the user has been using the Mini Program, the user login state remains valid. Specific aging logic is maintained by WeChat, transparent to developers. Developers only need to call wx.checkSession Interface detects whether the current user login state is valid.
After the login state expires, the developer can call the wx.login Gets the new user login state. Successful call indicates the current session_key Unexpired Invocation Failure Statement session_key Has expired. For more usage see Mini Program login。
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
# sample code
wx.checkSession({
success () {
//session_key Not expired and has been valid for the life cycle
},
fail () {
// session_key The logon process needs to be redone
wx.login() //Re-login
}
})