I am using the socket in javascript to emit data. Following is the code snippet.
socket.on('my response', function(msg) {
    $('#log').append('<p>Received: ' + msg.data + '</p>');
    /*
    if (window.performance) {
        console.info("window.performance work's fine on this browser");
    } 
    if (performance.navigation.type == 1) {
        console.info( "This page is reloaded" );
    } else {
        console.info( "This page is not reloaded");
    } */
    document.getElementById('div_id').innerHTML += msg.data + "<br>";
});
The problem is that the data I am displaying on the div is getting cleared once I reload the page. I want to retain the data and continue appending the data from msg.data even after I reload the web page. How can I achieve this? I was trying to detect page reload using the commented part in the above code snippet but it is detecting it as page reload event every time I get the msg.
UPDATE 1
If detecting reload event and using session-storage is the best way then I may have to emphasize on my main issue which is to detect a reload event. It's printing This page is reloaded every time I get data in msg.data(Using the commented part of the code snippet for detecting page reload event). I want to detect the only manual reloads and window.location.reload which I used from other modules of my code.
                        
Try something like this.