I am trying to remove the token cookie from the browser when logging out but with my current code that doesn't seem to be working. Also the Cookie.get() function is returning an empty object when a cookie is still visible in the browser. I have tried looking at other solutions but nothing seem to be working.
import { useNavigate } from "react-router-dom";
import history from "../../history";
import Cookie from "js-cookie";
export default function Tool() {
const navigate = useNavigate();
function logout() {
localStorage.clear();
Cookie.remove("token");
console.log(Cookie.get(), "Oooooooooooooo");
navigate("/login");
}
return (
<div >
<div className="topButtons">
<button onClick={() => logout()}>LogOut</button>
</div>
</div>
);
}