Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/nuxtPublic

Addrefresh option to useCookie() to extend cookie expiration #33811

Open
@riabinkovihor

Description

@riabinkovihor

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp