Setting Cookies using JavaScript in a local html file
From the MDC page for document.cookie
:
If not specified, [the
path
argument] defaults to the current path of the current document location.
So in your case, it will be /folder1/folder2/
.
I didn't initially see that you'd specified "local" in the question title -- not sure if this was updated while I was writing my answer. Cookies are not set when browsing using the file:///
protocol, depending on the browser.
Browsers do not store cookies for the file://
url protocol, it will simply and silently fail to set anything at all. So if this is truly "local" and not on a domain you may have a problem.
If you're on a mac, you can close Chrome and relaunch it like so:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-file-cookies
You'll then be able to set cookies on local files.
set --enable-file-cookies for chrome and it should work for you. Also, there are some features that you'll have to set "accept all cookies" also to make work, but if you do, make sure you set back before going back online.