Added profile data but clears after refresh
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user