Hi Leigh,
After advent of HTML5's web storage cookies are not preferred way to store some auxiliary data. Did you try using web storage?
https://blog.newrelic.com/2012/09/18/html5-web-storage-cookies-are-so-1994/
Regarding your condition, there has to be some initial case where in your cookie's value is null and you are setting it. I am not sure what logic are you using to set a cookie.
Thanks,
Chetan