2023-05-26 19:42:12 +00:00
|
|
|
<script setup>
|
|
|
|
useCookie('accessed-but-not-used')
|
|
|
|
useCookie('accessed-with-default-value', () => 'default')
|
|
|
|
useCookie('set').value = 'set'
|
|
|
|
useCookie('set-to-null').value = null
|
|
|
|
useCookie('set-to-null-with-default', () => 'default').value = null
|
2024-01-29 10:37:32 +00:00
|
|
|
|
|
|
|
const updated = useCookie('updated')
|
2023-05-26 19:42:12 +00:00
|
|
|
// the next set are all sent by browser
|
|
|
|
useCookie('browser-accessed-but-not-used')
|
|
|
|
useCookie('browser-accessed-with-default-value', () => 'default')
|
|
|
|
useCookie('browser-set').value = 'set'
|
|
|
|
useCookie('browser-set-to-null').value = null
|
|
|
|
useCookie('browser-set-to-null-with-default', () => 'default').value = null
|
2024-01-02 15:37:19 +00:00
|
|
|
|
|
|
|
const objectCookie = useCookie('browser-object-default', {
|
|
|
|
default: () => ({ foo: 'bar' })
|
|
|
|
})
|
2023-05-26 19:42:12 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>cookies testing page</div>
|
2024-01-29 10:37:32 +00:00
|
|
|
<pre>{{ updated }}</pre>
|
2024-01-17 11:53:14 +00:00
|
|
|
<button @click="objectCookie.foo === 'baz' ? objectCookie.foo = 'bar' : objectCookie.foo = 'baz'">
|
2024-01-02 15:37:19 +00:00
|
|
|
Change cookie
|
|
|
|
</button>
|
2024-01-29 10:37:32 +00:00
|
|
|
<button @click="refreshCookie('updated')">
|
|
|
|
Refresh cookie
|
|
|
|
</button>
|
2023-05-26 19:42:12 +00:00
|
|
|
</div>
|
|
|
|
</template>
|