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
|
|
|
|
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
|
|
|
|
2024-02-03 23:15:26 +00:00
|
|
|
const objectCookie = useCookie('browser-object-default')
|
|
|
|
const objectCookieSecond = useCookie('browser-object-default', {
|
2024-04-05 18:08:32 +00:00
|
|
|
default: () => ({ foo: 'bar' }),
|
2024-01-02 15:37:19 +00:00
|
|
|
})
|
2023-05-26 19:42:12 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>cookies testing page</div>
|
2024-02-03 23:15:26 +00:00
|
|
|
<pre>{{ objectCookieSecond.foo }}</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-02-03 23:15:26 +00:00
|
|
|
<button @click="refreshCookie('browser-object-default')">
|
2024-01-29 10:37:32 +00:00
|
|
|
Refresh cookie
|
|
|
|
</button>
|
2023-05-26 19:42:12 +00:00
|
|
|
</div>
|
|
|
|
</template>
|