If the Server accepts a connection with CleanSession set to 1, the Server MUST set Session Present to 0
in the CONNACK packet in addition to setting a zero return code in the CONNACK packet.
If the Server accepts a connection with CleanSession set to 0, the value set in Session Present depends on
whether the Server already has stored Session state for the supplied client ID. If the Server has stored
Session state, it MUST set Session Present to 1 in the CONNACK packet.
If the Server does not have stored Session state, it MUST set Session Present to 0 in the CONNACK packet.
This is in addition to setting a zero return code in the CONNACK packet.
The Session Present flag enables a Client to establish whether the Client and Server have a consistent view
about whether there is already stored Session state.
Once the initial setup of a Session is complete, a Client with stored Session state will expect the Server
to maintain its stored Session state. In the event that the value of Session Present received by the Client
from the Server is not as expected, the Client can choose whether to proceed with the Session or to disconnect.
The Client can discard the Session state on both Client and Server by disconnecting, connecting with
Clean Session set to 1 and then disconnecting again.
If a server sends a CONNACK packet containing a non-zero return code it MUST set Session Present to 0
If the Server accepts a connection with CleanSession set to 1, the Server MUST set Session Present to 0 in the CONNACK packet in addition to setting a zero return code in the CONNACK packet.
If the Server accepts a connection with CleanSession set to 0, the value set in Session Present depends on whether the Server already has stored Session state for the supplied client ID. If the Server has stored Session state, it MUST set Session Present to 1 in the CONNACK packet. If the Server does not have stored Session state, it MUST set Session Present to 0 in the CONNACK packet. This is in addition to setting a zero return code in the CONNACK packet.
The Session Present flag enables a Client to establish whether the Client and Server have a consistent view about whether there is already stored Session state.
Once the initial setup of a Session is complete, a Client with stored Session state will expect the Server to maintain its stored Session state. In the event that the value of Session Present received by the Client from the Server is not as expected, the Client can choose whether to proceed with the Session or to disconnect. The Client can discard the Session state on both Client and Server by disconnecting, connecting with Clean Session set to 1 and then disconnecting again.
If a server sends a CONNACK packet containing a non-zero return code it MUST set Session Present to 0