# wx.checkSession(Object object)

Checks if the login status has expired.

A user login status obtained via the wx.login API is time-sensitive. The Mini Program is more likely to expire when it is not used for a longer time. On the contrary, if the user keeps using the Mini Program, the user login status keeps effective. The specific time logic is maintained by WeChat and transparent to developers. Developers need only to call the wx.checkSession API to check whether the current user login status has expired.

After a login status expired, developers can call the wx.login again to get the latest user login status. If the API is called successfully, the current session_key remains effective; if the call to the API failed, the session_key has expired. For more usages, see Mini Program Login.

# Parameters

# Object object

Attribute Type Default Required Description
success function No The callback function for a successful API call
fail function No Callback function for failed API call
complete function No Callback function used when API call completed (always executed whether call succeeds or fails)

# Sample Code

wx.checkSession({
  success () {
    //session_key has not expired and will remain effective for the current lifecycle.
  },
  fail () {
    // session_key has expired and the user needs to log in again.
    wx.login() //Re-login
  }
})
点击咨询小助手