Toggle functionality in using localstorage and cookies