My html code like this :
<li id="login" class="hide-on-med-and-down">
<a class="dark-text" style="padding-right:0 !important" href="#">Login</a>
</li>
<li id="user-login">
<a class="white-txt dropdown-button" href="#" data-activates="user-dropdown">
<span id="current-lang" data-code="">085132112345</span>
<i class="fa fa-angle-down right"></i>
</a>
<ul id="user-dropdown" class="dropdown-content">
<li class=""><a href="#">Profile</a></li>
<li class="divider"></li>
<li class="active"><a href="#">Logout</a></li>
<li class="divider"></li>
</ul>
</li>
My javascript code like this :
var x = document.getElementById("login");
var y = document.getElementById("user-login");
if (localStorage.getItem("loginChelseaLocalStorage") === null) {
x.style.display = "block";
y.style.display = "none";
}
else {
x.style.display = "none";
y.style.display = "block";
}
If the user login, it will store on local storage like this :
localStorage.setItem("loginChelseaLocalStorage", true);
If the user logout, it will remove local storage like this :
localStorage.removeItem("loginChelseaLocalStorage");
Is the use of local storage to store login information as above is correct and good?