Skip to content
Web and HTTP2 min read

What are cookies?

Short answer

Cookies are small pieces of text a website sends to the browser, which stores them and sends them back with every later request to the same site. That's how a site remembers you're logged in or what's in your cart, because HTTP itself doesn't remember earlier requests.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Example: what a cookie looks like
  2. Cookie attributes
  3. Types of cookies
  4. Common problems
  5. On ArabyHost

The server sets a cookie with the Set-Cookie response header, and from then on the browser sends it back in the Cookie header with every request to that domain. Without cookies, visitors would have to log in again on every page, because HTTP is stateless.

Set-Cookie: session_id=a8f3c2; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=86400

On following requests, the browser sends:

Cookie: session_id=a8f3c2
Attribute What it does
Expires or Max-Age How long to keep it; without one it’s deleted when the browser closes (a session cookie)
Domain and Path Which domain and path it’s sent to
Secure Sent over HTTPS only
HttpOnly Hidden from JavaScript, protecting it from theft via XSS
SameSite Controls whether it’s sent with requests coming from other sites: Strict, Lax or None

Types of cookies

  • First-party cookies: set by the site you’re visiting; essential for logins, carts and language choice.
  • Third-party cookies: set by other domains, such as ad networks, to track users across sites; browsers restrict them more and more.

Common problems

  • WordPress login loop: the cookie isn’t saved because of a mismatch between www and non-www, or between HTTP and HTTPS. See login loop.
  • Laravel 419 error: the session cookie or its CSRF token expired. See 419 page expired.
  • The cache shows one user’s page to another: pages that depend on login or cart cookies must never be cached for everyone.
  • Cookie consent: data-protection laws in many countries require visitors to agree to non-essential cookies, so check local regulations.

On ArabyHost

Cookies with the Secure flag need HTTPS, and on ArabyHost a free SSL certificate is issued for every site automatically. On WordPress and WooCommerce sites, the LiteSpeed Cache plugin is aware of login and cart cookies, so one user’s personal pages aren’t served to others from the public cache. If you run into session problems, the Araby AI assistant reads the error log and explains the cause.

FAQ

Are cookies a privacy risk?

Cookies are plain text and can't run programs. The privacy concern comes from third-party cookies that follow you across sites for advertising, and you can block those in your browser settings.

What happens if I clear my cookies?

You're logged out of sites, unsaved carts are emptied and site preferences reset to their defaults. Clearing cookies is a common fix for login problems and redirect loops.

What's the difference between cookies and localStorage?

Cookies are sent to the server automatically with every request and each one holds about 4 KB. localStorage stays in the browser, is never sent to the server and holds more, but JavaScript can always read it.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.