What is the reason why the chrome browser cookie of Apple computer system can't be written into it?

the code is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function setc(name, value, expiresHours,domain) {
        var cookieString = name + "=" + (!!value?encodeURI(value):"");

        if(domain!=undefined)
            domain=";domain="+domain;
        else
            domain="";

        //
        if (expiresHours > 0) {
            var date = new Date();
            date.setTime(date.getTime() + expiresHours * 24 * 3600 * 1000);
            cookieString = cookieString + domain+"; path=/; expires=" + date.toGMTString();
        }

        document.cookie = cookieString;
    }

    setc("hasread",true,250)
</script>


</body>
</html>
Mar.17,2021

chrome cookie does not support local protocols, so you can access
through file://xxx.html if you access the file through a web server.

Menu