I’ve been trying to get cookies to work using Javascript, but I have got nothing so far.
I’ve tried different browsers (Microsoft Edge, Internet Explorer, and Opera so far), CodePen.io, and a VSCode live server add-on (by Ritwick Dey). The live server add-on shows the cookie for some reason though.
The Javascript:
document.cookie = "name=value";
alert(document.cookie);
And the html (if you need it):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
document.cookie = "name=value";
alert(document.cookie);
</script>
</body>
</html>
Really simple, but for some reason on every browser I’ve tried it shows nothing!
Reference Photo:
Cookie
Also I’m really new to javascript so it’s probably a very simple fix that I just can’t see.
And my first time using Stack overflow.


