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

164
Views
Unable to see JavaScript cookie in Developer tools or under cookie object

I'm very new to Javascript and I'm trying to create some cookies. I do not seem to be able to save them under document.cookie object for some reason. The main goal is to have a user write something in an text field and upon clicking a button it saves that input in a cookie and in js use document.getElementById("elementID").value; to get the value of the user input. I've tried to create a cookie manually like document.cookie = "name=samu"; but it also does not show. After googling this exact task I found the following page which had no problem creating a cookie from a user input in a text field. When checking under the developer tools > Application > Cookies I could see the cookie appear but I've even copy pasted the code and it did not work. I followed the W3school example on how to set and create one but also did not work.

HTML

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="Stylesheet1.css">
    <script type="text/javascript" src="objectosPredef.js"></script>
    <title>Actividad 2</title>
</head>
<body onload="listaPropiedades()">
    <div id="listaPropiedades"></div>
    <input type="text" id="nombre" placeholder="entra tu nombre" />
    <button onclick="crearCookie();">Click</button>

</body>

</html>

Javascript


function setCookie(nombre, valor, exp) {
    var d = new Date();
    d.setTime(d.getTime() + exp * 24 * 60 * 60 * 1000);
    var exp = "expires=" + d.toUTCString();
    document.cookie = nombre + "=" + valor + ";" + exp + ";path=/";
    alert(document.cookie);
}

function crearCookie() {
    var nombre = "nombre_usuario";
    var valor = document.getElementById("nombre").value;
    alert(valor);
    var exp = 500;
    setCookie(nombre, valor, exp);
    
}

I'm using Microsoft Visual Studio Community 2019

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

@mplungjan was right. I've downloaded Xampp and was able to save cookies and see them via the browser! thanks

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!