Data stored in sessionStorage gets cleared when the browser session ends code example
Example: clear session storage on refresh
window.onunload = function () {
sessionStorage.removeItem('key');
}
window.onunload = function () {
sessionStorage.removeItem('key');
}