• JMap.Event.User.on.sessionChanged

    This event is triggered when the user session has changed.

    If it's a logout, the accessToken in params.session is equal to "-1".

    Parameters

    • listenerId: string

      Your listener id (must be unique for all user events)

    • fn: ((params) => void)

      Your listener function

    Returns void

    Example


    // Each time the session has changed this method is processed
    JMap.Event.User.on.sessionChanged(
    "custom-session-change",
    params => {
    if (params.session.accessToken === "-1") {
    console.log("Session has been closed", params.session)
    } else {
    console.log(`New session opened`, params.session)
    }
    }
    )