Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cookie is not stored on chrome application

The cookie url_user is not stored, why?

This is the index.html:

 <!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
    integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script defer src="objectosPredef.js" pe="text/javascript"></script>
    <link rel="stylesheet" type="text/css" rel="noopener" target="_blank" href="mystyles.css">
</head>

<body>  

<button class="btn btn-danger" onclick="SetCoockie()">ESTABLECE COOCKIE</button>

</body>

</html>

This is the javascript "objectosPredef.js":

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function SetCoockie() {

    document.cookie = "url_usuario = myname";
}

enter image description here

Could you please help me?

>Solution :

Your code is OK, but it needs to be run from a server you will see your hostname is like http://localhost or http://example.com but you are running from the file system file://

You can use the LiveServer extension for vs code to run a local server for your HTML file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading