Back to overview
  • Artificial Intelligence

Local storage vs. cookies: the most important differences at a glance

  • Published March 20, 2023
  • Sarah Birk
  • Reading time: 8 min.

In order to offer users of an online shop an optimal experience, it is necessary to temporarily store user data using cookies. However, ever since the General Data Protection Regulation (GDPR) sparked the debate about the use of cookies in compliance with data protection regulations, alternatives have been increasingly used. This article highlights the differences between cookies, local storage, and session storage.

A person is sitting at a desk with a laptop and a bowl of cookies on it.

What are cookies?

Cookies are small data packets that computer programs exchange with each other. For example, an online shop that a customer visits stores a file on the customer's computer that contains information required for using the website, such as login data or the items in the shopping cart. With every https request (e.g., a request from the browser to the web server), the contents of the cookie are transmitted to the server.

A cookie stores various types of data, including personal data, such as:

  • a unique cookie number
  • individual settings (e.g., selected language, classification as B2B or B2C customer)
  • Number of visits to the website
  • entered data (e.g., name, email address)

Cookies help make your visit to the online shop more enjoyable: for example, your shopping cart remains intact if you accidentally close the page or reload it in an additional browser tab. Cookies also form the basis for the use of big data in e-commerce.

Note: At epoq,pseudonymizeddata is always used for personalization in order to ensure data protection with regard to cookies. For example, data such as click and purchase behavior is collected in pseudonymized form so that personal data can no longer be assigned to a specific data subject. This means that data that can be assigned to a person is not used for personalization.


Stay up to date on personalization: Sign up for the epoq newsletter.Register now!


The advantages of cookies at a glance:

  • Depending on the browser and version, approximately 150 to 180 cookies can be stored per domain.
  • Automatic sending of content to the server with every https request
  • Outsourcing of data that does not necessarily need to be stored on the server

Alternative to cookies: The Web Storage API

The Web Storage API contains objects that cache the data required by a website to optimize the user experience in the browser. This allows the server to access it directly. As a result, it is not necessary to transmit the data with every https request. Depending on the browser, the Web Storage API offers around 5 to 10 megabytes of storage capacity.

The advantages of the Web Storage API at a glance:

  • greater storage capacity than cookies
  • No expiration date for data storage (deletion is not easily possible)
  • Ideal for fast queries
  • particularly easy to implement
  • Supported by all common browsers
  • Can be used in offline mode

The Web Storage API distinguishes between two objects: session storage and local storage, which vary primarily in terms of their validity period.

Local storage: permanent storage of data

Data stored in the browser's local storage generally has no expiration date. This means that if customers close the open tab in their browser or the entire software, the data is still retained. For example, a website permanently "remembers" the language settings that visitors have selected. The data in local storage is available independently of the current browser tab, even if the user opens the online shop in multiple tabs.

Session storage: session-related, temporary storage

Data stored in session storage is only available for the duration of the current session. When the tab or browser is closed, the storage is automatically deleted. This is recommended for login data that should not be stored permanently.

Cookies vs. session storage vs. local storage: here are the differences

A direct comparison between cookies, session storage, and local storage reveals a number of differences:

  • File size: Cookies can be a maximum of 4,096 bytes in size, while local storage and session storage can each hold around 5 megabytes, or even 10 megabytes depending on the browser.
  • Performance: Local and session storage are generally better suited for fast queries than cookies. However, the more complex data the storage contains, the lower the performance during queries.
  • Effort: The effort required for implementation is significantly lower for local storage and session storage than for cookies. This is due to the complex structure of cookies, which represent a type of database.
  • Data transmission: Data is stored in the browser in local and session storage. The server accesses this locally stored data directly. Transmission does not occur automatically, but must be implemented. Cookies are also stored locally on the website visitor's computer. However, the data is sent to the server again each time a page is accessed.
  • Storage duration: Data stored in session storage is deleted when the tab/browser is closed. Cookies have an expiration date, but permanent storage is possible by setting a correspondingly late date. Local storage, on the other hand, remains intact until it is deleted by the user. There are also session cookies, which, like session storage, are automatically deleted at the end of the session.

Stay up to date on personalization: Sign up for the epoq newsletter.Register now!


Local storage vs. cookies: Which option is suitable in which situation?

Whether you prioritize session storage, local storage, or cookies for using your e-commerce technologies depends on what you want to store and how. The following best practices show the appropriate use in each case:

  • If you need more storage space, it is best to use local storage. For smaller amounts of data, both options are suitable.
  • If you don't want the stored data to expire, local storage is also the best choice. Session cookies and session storage are ideal for session-related expiration periods.

Local storage vs. cookies: What the GDPR and TTDSG say about this

With regard to the GDPR, local storage is preferable to cookies. The reason for this is simple: the data stored in cookies is sent to the server with every request. This means that personal information leaves the customer's computer. With local and session storage, the information remains stored locally on the computer. No personal data is transmitted; instead, it is processed directly in the browser.

Anyone involved in AI and data protection knows that visitors to an online store must actively consent to the processing of their personal data. This is regulated by the GDPR in conjunction with a ruling by the European Court of Justice (ECJ) on October 1, 2019.¹ As a result, you must set a cookie banner and obtain your customers' permission before setting cookies.

In addition to the GDPR, the"Act on Data Protection and Privacy Protection in Telecommunications and Telemedia"(TTDSG), which came into force in December 2021, now also comes into play. Section 25 (1) TTDSG specifies that the obligation to obtain permission does not only apply to cookies. Many operators are not yet aware that they also need the consent of visitors for the use of local and session storage

Conclusion: Local storage vs. cookies – exploit their full potential

The comparison between local storage and cookies shows that both options have their strengths and weaknesses. Therefore, make a conscious decision based on the intended use and take full advantage of their benefits. Incidentally, one does not have to exclude the other: depending on your needs, you can easily combine both options.

Sources: ¹ WBS Law, ² Cortina Consult

Frequently asked questions about local storage vs. cookies

Would you like to delve deeper into the topic of AI technology and learn how to create an AI-based knowledge base?

Schedule a web demo now.

Sarah, Junior Content Marketing Manager at epoq
Sarah Birk
Online Marketing Manager - Content & SEO
Sarah works as Online Marketing Manager – Content & SEO at Epoq and is responsible for the content area. Her responsibilities range from content planning and conception to analysis and optimization of various content formats, taking important SEO aspects into account.