If instead you'd like to know how to deal with Cookies from PHP, see HTML Cookies From PHP.
It looks like you're assigning to a variable, but it's really some sort of magic, because you can assign to it over and over again, and if you check the value of the document.cookie, you'll see all of the Cookies you set are in there.
You get all the Cookies that might apply to the current page, with the exception of Cookies with the HttpOnly attribute set. They all show up in one string:
If you need them individually, you can use split.
That will make an array like
To delete a Cookie, you assign to document.cookies exactly the same as when creating one. The only difference, is that you must specify an Expires attribute, and it must be in the past. Any time in the past will do, even one second in the past.
One thing I'm not covering is the Secure attribute. It works just like all of the rest, but I don't pay the extra to let you get to my site via https, so we couldn't set them nor see them.
Remember, this sets cookies on your machine. The domain will always be the same as the page so that you can set them, and see them. They will always be set to expire when the session is over unless you click the Date in past to delete? button to delete them. The Path is always '/'. Secure is never set.