Another newbie question

So, in my beginning javascript book in the chapter on cookies, the very first code example given doesn’t work.

<!DOCTYPE html>

<html lang="en">
  <title>Fresh-Baked Cookie</title>
    document.cookie = "UserName=Paul; expires=Tue, 28 Dec 2020 00:00:00;";
  <p>This page just created a cookie</p>


I open that file in MS Edge, there is no cookie. In FireFox, no cookie. In Chrome it shows a cookie, but with no description or name and nothing in it. In IE11, it shows a link to the file (it’s on my desktop) and when I open the “cookie” it contains:

“Cookies are no longer stored in files. Please use InternetCookie APIs to access cookies.”

According to the book, I should have a neat little cookie with the data in it.

What gives?

Just glancing at the code, so there may be other issues, but cookies cannot contain whitespace; what you have there cannot be valid

Edit you can either just make sure there’s no whitespace, or you can use this function to encode the string properly and try setting it once it’s been through that:

I copied your code into my VSCode, saved as an HTML file, then was able to open it in both Chrome and FireFox (I am using a Mac so no MS Edge or Explorer 11 until I get my Windows machine back up).

In both I saw the title and the text “this page created a cookie”.
I found the cookie for Firefox easily in the WebDev tools/console. Took some doing to find it in Chrome (and had to google that) but it was there.

So not sure why it isn’t working on the Windows platform? DanCouper’s advice may be what you need though.