You can use session storage, which doesn't have an expiry which will look like this:
<script>
sessionStorage.setItem('lastname','Smith');
alert(sessionStorage.getItem('lastname'));
</script>
I hope this will help.
Want to become a Java Expert? Join Java Certification now!!
Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Programming :