cookieconsent icon indicating copy to clipboard operation
cookieconsent copied to clipboard

[Bug]: The setCookieData() method can accidentally delete the lastConsentTimestamp field from the cc-cookie

Open peaemaye opened this issue 1 year ago • 0 comments

Expected Behavior

Calling setCookieData() should update the cookie data field without removing the lastConsentTimestamp from the cookie.

Current Behavior

There are some rare circumstances where calling the setCookieData() method causes the lastConsentTimestamp field on the cookie to be lost. Only happens if it's called when the state is otherwise unchanged as state._savedCookieContent.lastConsentTimestamp is only set in the saveCookiePreferences() method if the state has changes or the current consent is invalid.

Steps to reproduce

See this codesandbox for a minimal repro https://codesandbox.io/p/sandbox/cookieconsent1-8jyvgt?file=%2Findex.js (seems to work better with cookies than StackBlitz)

It's a bit a of a contrived example but I think demonstrates the issue without having to involve iframemanager like my real world use case.

Proposed fix or additional info.

See PR: https://github.com/orestbida/cookieconsent/pull/701

Version

3.0.1

On which browser do you see the issue?

Chrome

peaemaye avatar Jun 27 '24 11:06 peaemaye