With JavaScript, a cookie can be created like this: document.
If you provide this attribute with a valid date or time, then the cookie will expire on a given date or time and thereafter, the cookies' value will not be accessible. As soon as personalization was invented, this became a major problem.
This script was originally written by Scott Andrew. For more information on how to use relative paths, see this paragraph. The following function can translate relative paths to absolute paths. The protection is quite reliable. Finally, to remove a cookie, set it with an expiry date before today.
The strict value will prevent the cookie from being sent by the browser to the target site in all cross-site browsing context, even when following a regular link. Some examples of its usage: Cookies.
We leave it as an exercise for the reader. Fully working though.