Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! I need a cookie...

Status
Not open for further replies.

skytiger33

Technical User
Feb 11, 2001
1
US
My boss gave me the following instructions to create a JavaScript cookie for our site. I have no idea how to do this. Any (helpful) suggestions are welcome!

When a visitor arrives at our site from an offsite link, the URL may look like this:
"
Create Cookie:
1. Detect a query string in a URL that brought a web site visitor to our web site.
2. If that query string exists, save it as a cookie.
3. Set the cookie to expire in a week.

Read Cookie:
1. Detect if values are assigned for specific variables
2. If assigned, provide ability to embed values into web pages and forms as a field default or the value of a hidden field.
 
My first thoughts on seeing this were "That's not possible - you need a server side scripting language."

But then I tried it and it worked! Actually, I am amazed myself - I didn't think it would be possible, so now I know too.

It's still posted up at - have a go at putting your own variables into the address (eg .../locat.html?a=0&b=1&c=2) , and do a view source to see how it works.

I'd still recommend learning a server-side scripting language though as you'll be able to do a lot more with it.

Matt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top