Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.5k
Open
Labels
Description
Describe the feature
Add arefresh option to theuseCookie composable to allow extending the cookie expiration
even when the value remains unchanged. This is useful for cookies that should stay alive
as long as the user is active, without changing the value.
Current behavior
When updating a cookie with the same value, its expiration time does not reset.
Expected behavior
With a new optionrefresh: true, setting the cookie even to the same value
should update the expiration time according tomaxAge.
Example
<script setup lang="ts">const testCookie=useCookie('test-cookie', { maxAge:60*60,default: ()=>'defaultValue', refresh:true,})if (import.meta.server) {testCookie.value='defaultValue'// cookie expiration should be extended}const changeCookie= ()=> {testCookie.value='defaultValue'// cookie expiration should be extended}</script><template> <div> testCookie: {{ testCookie }} <button@click="changeCookie"> change cookie </button> </div></template>
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read thecontribution guide.
- Check existingdiscussions andissues.