anchor.diff:      try xmpp:try_subtag(IQ, #bind{}) of
   	#bind{jid = #jid{user = U, server = S, resource = R}} ->
   	    State2 = State1#{user => U, server => S, resource => R},
  -	    State3 = try callback(handle_bind_success, State2)
  -		     catch _:{?MODULE, undef} -> State2
  -		     end,
  -	    process_stream_established(State3);
  +	    case maps:get(session_response_id, State2, undefined) of
  +		undefined ->
  +		    State3 = try callback(handle_bind_success, State2)
  +			     catch _:{?MODULE, undef} -> State2
  +			     end,
  +		    process_stream_established(State3);
  +		SID ->
  +		    Pkt = #iq{id = SID, type = set, to = jid:make(S),
  +			      sub_els = [#xmpp_session{}]},
  +		    State3 = State2#{stream_state => wait_for_session_response},
  +		    send_pkt(State3, Pkt)
  +	    end;
   	#bind{} ->
   	    Txt = <<"Missing <jid/> element in resource binding response">>,
   	    send_pkt(State1, xmpp:serr_invalid_xml(Txt, Lang));
  
positive.code: 		      sub_els = [#bind{resource = R}]},
  	    State1 = State#{stream_state => wait_for_bind_response,
  			    bind_id => ID},
  	    send_pkt(State1, Pkt);
  	false ->
  	    Txt = <<"Missing resource binding feature">>,
  	    send_pkt(State, xmpp:serr_invalid_xml(Txt, Lang))
  
negative.code: reset_bind_state(State) ->
      maps:remove(bind_id, State).
  
  -spec reset_session_state(state()) -> state().
  reset_session_state(State) ->
      maps:remove(session_response_id, State).
  
  -spec reset_state(state()) -> state().
  reset_state(State) ->
      State1 = reset_bind_state(State),
      State2 = reset_sasl_state(State1),
      State3 = reset_connection_state(State2),
      State4 = reset_session_state(State3),
      reset_stream_state(State4).
  
  %%%===================================================================
  %%% Connection stuff
  