Added profile data but clears after refresh

This commit is contained in:
2023-10-24 01:25:12 -07:00
parent e0fb79f2c9
commit 07a40ee808
5 changed files with 37 additions and 5 deletions
+2 -1
View File
@@ -31,8 +31,9 @@ function MyApp({ Component, pageProps }) {
}
};
// Attach the event handler when the component mounts
useEffect(() => {
// Attach the event handler when the component mounts
window.onpopstate = handlePopState;
// Clean up the event handler when the component unmounts
+2 -1
View File
@@ -8,8 +8,9 @@ import { deleteCookie } from "cookies-next";
export default function Logout() {
const router = useRouter();
const handleLogout = () => {
// Remove the cookie
// Remove the cookie and local storage
deleteCookie("cmc-token");
localStorage.removeItem("cmc-profile");
// Use replaceState to replace the current URL with the root URL
window.history.replaceState({}, document.title, window.location.href);