Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why doesn't the cookie expire automatically? #27848

Closed
castrogarciajs opened this issue Jun 26, 2024 · 1 comment
Closed

Why doesn't the cookie expire automatically? #27848

castrogarciajs opened this issue Jun 26, 2024 · 1 comment

Comments

@castrogarciajs
Copy link

castrogarciajs commented Jun 26, 2024

Environment


  • Operating System: Windows_NT
  • Node Version: v20.14.0
  • Nuxt Version: 3.12.2
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.6
  • Package Manager: pnpm@9.4.0
  • Builder: -
  • User Config: modules, colorMode, fonts, vite, build, scripts, $production, eslint
  • Runtime Modules: @nuxt/ui@2.17.0, @nuxt/fonts@0.7.0, @nuxt/image@1.7.0, @nuxt/devtools@1.3.6, @nuxt/eslint@0.3.13, @nuxt/scripts@0.5.1, @pinia/nuxt@0.5.1, @pinia-plugin-persistedstate/nuxt@1.2.0
  • Build Modules: -

Reproduction

The description of the cookie says it is a session cookie.

image

Describe the bug

I have this code:

<script setup lang="ts">
import type { OptionsRequest, ResponseBanners } from '@/utils/types'

definePageMeta({
  middleware: ['get-orders'],
})

const layout = 'domiplace'
const address = useAddress()
const loading = useLoading()
const customer = useCustomer()
const advertisementCookie = useCookie('advertisement')
const cancelAdvertisement = useCookie('cancel-advertisement')
const advertisement = useAdvertisement()

const { ENDPOINT_CUSTOMER } = ENDPOINTS

async function getAdvertisement() {
  const bannerOptions: OptionsRequest = {
    method: 'POST',
    body: {
      idCity: address.zone.address,
    },
  }

  const { data } = await useRequest<ResponseBanners>(ENDPOINT_CUSTOMER.banners, bannerOptions)

  if (Array.isArray(data.banners) && data.banners.length) {
    const filteredBanners = data.banners.filter(banner => banner.location.ubi === 1)

    if (filteredBanners.length) {
      advertisement.onBannersAdvertisement(filteredBanners)
      advertisementCookie.value = 'on'
    }
    else {
      advertisementCookie.value = ''
    }
  }

  return data.banners
}

const banners = await getAdvertisement()

if (advertisementCookie.value && !cancelAdvertisement.value && Array.isArray(banners) && banners.length) {
  advertisement.onModalAdvertisement(true)
  cancelAdvertisement.value = 'on'
}

await useCommerces(customer.currentCategory)

loading.setEdit(false)
</script>

The idea is that the cancelAdvertisement cookie is deleted when closing an instance of the browser but this never happens in the documentation says that it does it by default but I do not know why in my case keeps the value set.

Am I doing something wrong?

Additional context

No response

Logs

No response

Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants