Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

71
Vistas
Mobile Google Chrome not sending the cookies

I wrote a simple Express.js server which only sets a cookie named hello-world and returns the request headers. Here is the code:

const app = require('express')()

app.get('/', (req, res) => {
  res.cookie('hello-world', 'this-is-the-value-of-cookie')
  res.json(req.headers)
})

app.listen(80, '0.0.0.0')

The problem is that mobile Google Chrome dose not send the cookies in the first request. Here is a demo of it: https://file.io/OIilmHoA2IKK

In the demo, I use the Android Studio's emulator and nip.io wildcard DNS. I simply start the Express.js server on my local machine and then access it via http://10.0.2.2.nip.io

As you can see in the demo, I first open the page and refresh to make sure hello-world cookie is set. Then I close Google Chrome and reopen it again. But the first time I open the page, there is still no hello-world cookie.

What did I do wrong here? I want the hello-world cookie be sent even in the first request after browser restarts.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It is not entirely clear from you code snippet, but I assume that you are creating a session cookie instead of a persistent cookie. Therefore the cookie is gone, when you close and reopen the browser.

You can create a persistent cookie by adding an expiration date to your cookie value. Your cookie will be stored until it expires (or is deleted by the user). That date parameter has to be formatted as a UTC string. You could do it like this:

res.cookie('hello-world', 'this-is-the-value-of-cookie', { expires: new Date(2030, 0) });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda