Title: Close session
Last modified: October 11, 2021

---

# Close session

 *  Resolved [toyataupitz1995](https://wordpress.org/support/users/toyataupitz1995/)
 * (@toyataupitz1995)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/close-session/)
 * Hello, is it possible that the chat window always starts over and does not always
   start where you left off the last time. Every time I come to the site, the last
   session is saved and continued there. But I want a new one to start over and 
   over again, is that possible?
 * Best reagrds
    Toya

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [kamiltidio](https://wordpress.org/support/users/kamiltidio/)
 * (@kamiltidio)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/close-session/#post-14962123)
 * Hi!
 * Thank you for writing in.
    While we do not have a built-in option like that, 
   as the chat history is saved in the local storage of the web browser – we do 
   have a workaround for it.
 * Please simply paste this code and change the “PK” from the ‘tidio_state_PK’ to
   your own Public Key which can be found in the Developer section of Tidio. [https://www.tidio.com/panel/settings/developer](https://www.tidio.com/panel/settings/developer)
 * After the code is injected correctly – it will clear the whole chat after reloading
   the page.
 *     ```
       window.addEventListener('beforeunload', function(){
       const stateKey = 'tidio_state_PK';
       const state = JSON.parse(localStorage.getItem(stateKey));
       console.log(state.messages)
       const newState = {...state, messages: []}
       localStorage.setItem(stateKey, JSON.stringify(newState));
       })
       ```
   
 *  Thread Starter [toyataupitz1995](https://wordpress.org/support/users/toyataupitz1995/)
 * (@toyataupitz1995)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/close-session/#post-14962410)
 * Hello,
 * okay but i’m so sorry i dont understand where i have to put this code and what
   i do with the “PK”
 * [https://my.hidrive.com/lnk/DBRkLlTx](https://my.hidrive.com/lnk/DBRkLlTx)
 * here are the settings and where must i put the this code?
 *  Plugin Support [kamiltidio](https://wordpress.org/support/users/kamiltidio/)
 * (@kamiltidio)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/close-session/#post-14963724)
 *     ```
       window.addEventListener('beforeunload', function(){
       const stateKey = 'tidio_state_u3abhqrefntf1eidhqkakxnno6vecorr';
       const state = JSON.parse(localStorage.getItem(stateKey));
       console.log(state.messages)
       const newState = {...state, messages: []}
       localStorage.setItem(stateKey, JSON.stringify(newState));
       })
       ```
   
 * Hi! Thank you for writing back.
    In your case the code should be as above – you
   can put it below Tidio code in your page.
 * I’ll be here in case of any further questions!
 *  Thread Starter [toyataupitz1995](https://wordpress.org/support/users/toyataupitz1995/)
 * (@toyataupitz1995)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/close-session/#post-14972633)
 * Hello,
 * [https://my.hidrive.com/lnk/ByRELHNq](https://my.hidrive.com/lnk/ByRELHNq)
 * i put this code see in the pic into footer.php
 * But it doesnt’s clear the chat after Reloading the page.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Close session’ is closed to new replies.

 * ![](https://ps.w.org/tidio-live-chat/assets/icon-256x256.gif?rev=3465139)
 * [Tidio – Live Chat & AI Chatbots](https://wordpress.org/plugins/tidio-live-chat/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tidio-live-chat/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tidio-live-chat/)
 * [Active Topics](https://wordpress.org/support/plugin/tidio-live-chat/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tidio-live-chat/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tidio-live-chat/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [toyataupitz1995](https://wordpress.org/support/users/toyataupitz1995/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/close-session/#post-14972633)
 * Status: resolved