KanHarI / vue3-cookies

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

Expiration always set to 'Session' #5

Open leonardogruppelli opened 3 years ago

leonardogruppelli commented 3 years ago

I've followed the documentation to configure the package on my Vite project.

This is my main.js file, using globalCookiesConfig.

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { globalCookiesConfig } from 'vue3-cookies'
import router from '~/router'

import App from '~/App.vue'

import '~/assets/styles/index.css'

globalCookiesConfig({
  expireTimes: '7d',
  path: '/',
  secure: true,
  sameSite: 'None',
})

createApp(App).use(router).use(createPinia()).mount('#app')

Even though expireTimes is being set in the global configuration, all cookies are being created with the expiration set to Session.

Melbourneandrew commented 2 years ago

I am also experiencing this. Any fix?

ghdl023 commented 1 year ago

I am also experiencing this. Any fix?

Melbourneandrew commented 1 year ago

I got it working with this in my main.js

import { globalCookiesConfig } from "vue3-cookies";

globalCookiesConfig({
  expireTimes: "30d",
  secure: true,
  sameSite: "Strict",
});
jacobgoh101 commented 1 year ago

I am still facing this issue today.

fixed by using vanilla js

document.cookie = `token=${token}; expires=${expires}; path=/`;
SiDawg commented 1 year ago

I got it working with this in my main.js

import { globalCookiesConfig } from "vue3-cookies";

globalCookiesConfig({
  expireTimes: "30d",
  secure: true,
  sameSite: "Strict",
});

This works for me when using localhost:8080:

These scenarios in global config result in "session" cookie only for me, ignoring expiry time (e.g. 30d as above):

These scenarios result in expected behaviour, as long as I omit path: entry

Other notes

Publishing to my github page https://sidawg.github.io/Vuetar/ (first line = config scenario, bullets = reported in browser cookie info). I'm about 90% sure below is captured correctly :D Note i also have 'sameSite: "None"' (and secure = true)

Path omitted and (domain omitted or domain = "")

Path omitted and domain as sidawg.github.io

(Path = "/Vuetar" or Path = "/") and (domain = "" or domain = "sidawg.github.io" or domain omitted)

So localhost and Github pages behaviour consistent. I think conclusions something like: