0

I am working on Reactjs and using nextjs framework,I used cookie for user login and now at logout time i want to delete/remove cookie,How can i do this ? here is my code for add cookie

Cookies.set('email', email )

Julia
  • 1
  • 1
  • 1
    Does this answer your question? [Delete cookie by name?](https://stackoverflow.com/questions/10593013/delete-cookie-by-name) – Dan Philip Bejoy Dec 13 '22 at 04:17
  • @DanPhilipBejoy no i am working with Nextjs – Julia Dec 13 '22 at 04:31
  • guess this work should be done right before calling the api. How do you call the apis? there should be kinda option for manipulating it. Seems not highly related to the React.js – kyuhyun Dec 13 '22 at 04:56

1 Answers1

0

I think you're using the package js-cookie

To remove the cookie while logging out call Cookies.remove('email') at the end of the handler function.

If the log out call returns a positive response for successful logout, then maybe use that as a condition for removing the cookie.

Badal Saibo
  • 2,499
  • 11
  • 23