3

I have a VueJS UI that runs on the port 8080, whereas my Node server which handles the auth runs on 8082. After login our Auth server redirects back to the UI, and sets the required session cookie. I need to set this cookie to null in my frontend when I click the Logout button, before redirecting to the server Logout action which takes care of the backend details.

I am not able to access document.cookie, or delete the cookie using Vue.cookie. Both of these return the cookie value as null. How would I do it?

Rutwick Gangurde
  • 4,772
  • 11
  • 53
  • 87

1 Answers1

4

To properly delete a cookie, do the following:

function delete_cookie(name) {
  document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

Source

Saddy
  • 1,515
  • 1
  • 9
  • 20