I'm fairly new to javascript, and I'm having a lot of trouble with cookies. Here's what I would like to do... visitor clicks: test.com/blah.html or test.com/blah.html?hello=world * javascript works its magic * visitor is redirected to: test.com/blah.html?cookievar1=whatever&cookievar2=whatever&cookievar3=whatever... or test.com/blah.html?hello=world&cookievar1=whatever&cookievar2=whatever... The reason I would like to do it this way is because my webpages are generated on the fly as people visit them and the page content is based on the href list. I've checked a number of password cookie demos, but they all assume the page being linked to is static. Like I said, I have very little experience with javascript, so any help would be appreciated!
Cookies are not automatically added to the query string - but you can add anything to the query string you want. If the items have to be in cookies - just write them to a cookie (there are good generic functions available at Quirksmode for read, write & erase cookies). Then just do this: var u = document.location.href; while(haveMoreCookies()) { var c = readNextCookie(); u += "&"+c.name+"="+c.value; } Then you will have a new URL with the variables added to it and you can do something like this in Javascript to effect the redirect: document.location = u; You may need to modify the above slightly so the first variable gets a "?" instead of a "&" - but that is not too hard.