local storage check if key exists php code example Example: local storage check if key exists if (localStorage.getItem("username") === null) { //... }