The refreshCookie function is designed to refresh cookie value returned by useCookie.
This is useful for updating the useCookie ref when we know the new cookie value has been set in the browser.
<script setup lang="ts">
const tokenCookie = useCookie('token')
const login = async (username, password) => {
const token = await $fetch('/api/token', { /** ... */ }) // Sets `token` cookie on response
refreshCookie('token')
}
const loggedIn = computed(() => !!tokenCookie.value)
</script>
cookieStore option is enabled by default. It automatically refreshes the useCookie value when cookies change in the browser.export function refreshCookie (name: string): void