Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Cómo hacer una cookie, que es aleatoria y no cambiará una vez que el usuario regrese (no puede ser PHPSESSID= porque estoy ejecutando node.js)

Estoy tratando de crear una cookie que actúe como un PHPSESSID pero que sea JavaScript, solo usaría PHP pero estoy ejecutando un nodo, por lo que es imposible. La esperanza es que obtenga una identificación de 7 caracteres largos que permanezca incluso cuando vuelva a cargar la página y no se pueda replicar. Esto es lo que he intentado, pero crea uno nuevo en lugar de mantenerlo cada vez.

 function randomString() { //define a variable consisting alphabets in small and capital letter var characters = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; //specify the length for the new string var lenString = 7; var randomstring = ''; //loop to select a new character in each iteration for (var i=0; i<lenString; i++) { var rnum = Math.floor(Math.random() * characters.length); randomstring += characters.substring(rnum, rnum+1); } var thing = randomstring; document.cookie = `${thing};expires=4000;` }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Ok, acabo de probar el domain=https://example.com/; y eso funcionó, tal vez haya una mejor manera de publicar otras respuestas. código completo,

 function randomString() { //define a variable consisting alphabets in small and capital letter var characters = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; //specify the length for the new string var lenString = 7; var randomstring = ''; //loop to select a new character in each iteration for (var i=0; i<lenString; i++) { var rnum = Math.floor(Math.random() * characters.length); randomstring += characters.substring(rnum, rnum+1); } var thing = randomstring; document.cookie = `${thing};expires=4000;domain=https://eez.penguinpowers.repl.co;` }
about 4 years ago · Juan Pablo Isaza Report

0

express-session, es básicamente PHPSessionID pero para Express.js
( enlace )

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!