Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
Set cookie to redirect user if set cookie exists

I have some experience with JavaScript, but I'm racking my brain with cookies. I'm trying to set a cookie for users who access page X, and then redirect them to that same page X if they visit page Y.

See a more detailed example:

When a user visits https://www.example.com/page.html, I need a cookie to be set.

When this same user visits https://www.example.com/redirect.html, I need to check if the cookie that was set on https://www.example.com/page.html exists, if it exists then this user must be redirect to https://www.example.com/page.html.

Basically it's setting a cookie, if that cookie exists then something happens. I know how to do the redirect with JavaScript, but how do I set and read this cookie?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can create routes and set and receive cookies in the request and response object.

Set a cookie like this: res.cookie(cookie_name,cookie value);

Read a cookie like this: req.cookie['cookie_name'];

More about using cookies here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda