title: MQTT Clean session
body: <p>Assume that I connected to the broker with "clean session=false" and started receiving events, in case of disconnection ideally my application will still receive data on connection. But if the application is crashed I want to have a fresh start and clear my session.</p>
  
  <p>Can I clear my session on the MQTT broker and have a fresh start?</p>
  
  <p>From the documentation I concluded that if I wanted to do that I would need to do the following: </p>
  
  <ol>
  <li><p>application start </p></li>
  <li><p>connect using "clean session=true" // this will cause any current session to be removed along with its data </p></li>
  <li><p>every thing related to the session is purged from server </p></li>
  <li><p>disconnect </p></li>
  <li><p>connect using "clean session=false" and start getting the data.</p></li>
  </ol>
  
  <p>I got the idea from
  <a href="http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-establishment" rel="nofollow noreferrer">http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-establishment</a></p>
  
  <blockquote>
    <p>"If clean session is set to true, the broker won’t store anything for
    the client and will also purge all information from a previous
    persistent session."</p>
  </blockquote>
  
  <p><strong>Is this the correct way to clear a previous session?</strong></p>