cmp-cc / vue-cookies

A simple Vue.js plugin for handling browser cookies
MIT License
408 stars 70 forks source link

httpOnly? #85

Open bahiamartins opened 1 year ago

bahiamartins commented 1 year ago

missing httpOnly

cmp-cc commented 1 year ago

HttpOnly cannot be set in the browser client side (in JavaScript). there's no API available to get/set the HttpOnly attribute of the cookie, as that would otherwise defeat the meaning of HttpOnly.

see #51

wshostak commented 1 year ago

In my case I just need to make sure the session exist so I wrote this function;

  methods: {
    doesSessionExist(cookieName) {
      this.$cookies.set(cookieName, 'new_value', '1s')

      return !this.$cookies.get(cookieName)
    }
  }

and call like so this.doesSessionExist('session_cookie_name') if you can set the cookie it does not exist.