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

159
Views
sessionStorage devuelve nulo

Tengo este método de publicación donde tengo el nombre de usuario variable, variable cuyo contenido necesito usar en otro archivo js. En este método uso sessionStorage.setItem().

 app.post('/auth', function(request, response) { var username = request.body.username; var password = request.body.password; sessionStorage.setItem('user', JSON.stringify(username)); if (username && password) { connection.query('SELECT * FROM usuarios WHERE nombre_usuario = ? AND password_usuario = ?', [username, password], function(error, results, fields) { if (results.length > 0) { request.session.loggedin = true; request.session.username = username; response.redirect('/home'); } else { response.send('Incorrect Username and/or Password!'); } response.end(); }); } else { response.send('Please enter Username and Password!'); response.end(); } });

Luego, como dije, necesito la variable de nombre de usuario en otro archivo js. Para eso uso sessionStorage.getItem(), pero siempre devuelve nulo.

 case "based": // INSERT INTO BD states, Q and type of automaton, M console.log("the username is " + sessionStorage.getItem('user')); var state = this.chart.obtainStates(); console.log ("the state is " + state); var state2 = state.split("x",1); console.log ("the state2 is " + state2); } }

¿Qué tengo que hacer?

about 4 years ago · Juan Pablo Isaza
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!