Use of document.cookie in Safari

Are there scoping issues with document.cookie in Safari?

I have written a javascript constructor function around document.cookie. The constructor function is defined in the global scope but is used inside of another object instance. It works in Firefox and Chrome but does not work in Safari.

If I do window.onload = function() { var ck = 'test=this; max-age=600; domain=localhost; path=/dev_lab_current/lab_56; SameSite=Lax'; document.cookie = ck; } it works. But it does not set the cookie in my html application. The application has a host object constructor that creates an instance of the cookie manager constructor within it. So it is about 2 scope levels deep. But the exact same code DOES work in Firefox and Chrome.

The html is designed to allow hard coded records to be kept for cookies created by it. PHP is used to write the hard coded records in a javascript source code file. For this reason I would not post a demo on my publically available web site.

Thank you for time and attention JK

I am answering my own post with an update: I solved the issue. The string used to set the cookie had syntax that Safari, and Opera would not allow.

That was due to a subtile and important issue with a for loop: a missing break statement.

So the difference between Safari (and Opera) and Firefox, Chrome is the cookie string syntax.

If secure is specified, it should be in the string by itself and not set to anything. The issue I tracked down was that 'secure=false;' was showing up in the string when it is just set by the presence of absence of 'secure'

Thank you for time and attention JK

Use of document.cookie in Safari
 
 
Q