Secure Privacy

Secure Privacy Consent Storage: localStorage Keys, Lifetime and Consent Logs

Secure Privacy stores each visitor’s consent choice in browser localStorage, not a cookie. See how localStorage differs from cookies, what each sp_ item stores, how long consent lasts and where consent logs are kept.

SPT
Secure Privacy Team
5 min read

If you check the cookies on your website, for example with a cookie scan or in your browser's cookie list, you won't find a Secure Privacy consent cookie. That's because Secure Privacy saves each visitor's consent choice in the browser's localStorage, and keeps a separate record of every choice in its consent logs.

This article explains what localStorage is and how it differs from cookies, lists the items Secure Privacy stores and how long they last, and shows where consent logs are kept and how to check it all in your own browser.

Please note: this article is general product information about how Secure Privacy works. It is not legal advice, and it is not a legal statement or proof of compliance for your website. For legal questions, please consult your own legal advisor.

What Is localStorage and How Is It Different from Cookies?

localStorage is a small storage area built into every modern browser. A website can use it to save short pieces of text on the visitor's device, so they are still there on the next visit.

The main difference is how the data is set and shared. Cookies can be set by the website's server without any script running, and the browser sends them back automatically with every request to that domain. localStorage is only written or read when a script running on the page, such as the Secure Privacy banner, asks for it, and the browser never sends it anywhere on its own.

Cookies

localStorage

How it's set

By the server in its response, or by a script on the page

Only by a script running on the page

Sent to the server

Automatically, with every request to the matching domain

Never automatically

Expiry

Built-in expiry date

No built-in expiry; stays until removed

Scope

Can be shared across subdomains

Limited to one website origin

Size

Around 4 KB per cookie

Around 5 MB per website

For more on how cookies are used to follow visitors across sites, read our guide to tracking and advertising cookies.

Secure Privacy localStorage Keys: sp_consent, sp_dynamic and sp_expiry

When a visitor makes a choice on your cookie banner or preference center, the Secure Privacy script saves these items in localStorage on your domain:

Key

What it stores

sp_consent

The visitor's choice for each consent category, such as Analytics or Advertising

sp_dynamic

Details the banner needs on return visits: the visitor's detected location, a client ID and sub-consents (choices for individual services)

sp_expiry

The date and time when the stored consent expires

On every page load, Secure Privacy reads these items to apply the visitor's choice without showing the banner again. You may also see other keys starting with sp_, depending on the features enabled on your domain.

The stored choice lasts until the date in sp_expiry, typically 12 months from the visitor's choice, depending on your consent template settings. After that, the banner is shown again.

It can end earlier if the visitor clears their browser data or uses a private window, or if the browser removes it. Safari, for example, deletes script-written storage, including localStorage, after seven days of Safari use without a visit to your site.

Visitors can change their mind at any time with the Withdraw consent button in the preference center. All categories except Essential are switched off, and the withdrawal is reflected both in the visitor's browser and in Secure Privacy's consent records.

Alongside the browser storage, each consent choice is recorded on Secure Privacy's servers. You can see these records in the Consent dashboard, with the date and time, consent status, category choices, an anonymized IP address, location and device details, and export them to CSV.

How long consent logs are kept depends on your Secure Privacy plan and data retention settings.

These steps use Chrome or Edge. In Firefox and Safari, use the Storage tab instead of Application.

Open your website and accept, decline or save your preferences. The items are only saved once a choice has been made.

Step 2 - Open Local storage in developer tools

Press F12 (Cmd+Option+I on a Mac), open the Application tab, expand Local storage and select your website's address. Each subdomain, including www and non-www, has its own localStorage.

Step 3 - Filter for sp_ keys

Type sp_ in the filter box and select a key to see its value. To see the banner again as a new visitor, delete the sp_ keys and reload the page.

Developers can also read the current choices in the browser console with sp.allGivenConsents, described in the Secure Privacy JavaScript API reference.

Frequently Asked Questions

Secure Privacy doesn't use a cookie to store consent. The visitor's choice is saved in browser localStorage under sp_consent, together with sp_dynamic and sp_expiry.

Until the date stored in sp_expiry, typically 12 months from the visitor's choice, depending on your consent template settings.

What is the difference between localStorage and cookies?

Cookies can be set by the server and are sent back automatically with every request. localStorage is only written or read by a script running on the page and is never sent automatically.

Yes. The Withdraw consent button in the preference center switches off all categories except Essential, and the withdrawal is reflected in both the browser and Secure Privacy's consent records.

On Secure Privacy's servers, viewable and exportable from the Consent dashboard. How long they are kept depends on your plan and data retention settings.

Have a question about how Secure Privacy stores consent? Contact Secure Privacy support.

Want to see Consent Management in action?

Explore Consent Management

Need more help?

Our privacy experts are here to guide you through complex regulations and find the right solution.

Contact Support

Related Articles

View all