PDA

View Full Version : Cookie help


Wobbler
10-01-2002, 08:31 PM
Can sombody help me make this cookie to html code so if you:

Enter the index.htm page a splash image will be shown, and under the image there is a checkbox.
When you check that box it will save a cookie that makes when you you visit the site next time you will enter index2.htm page directly instead to click the splash image at the index.htm page!!


' Update cookie if box checked
if Request.Form.Count > 0 then
Response.Cookies("goupdates") = Request.Form("goupdates")

' The Cookie send only to first page
' on www.???.com
Response.Cookies("goupdates").domain = "www.???.com"
Response.Cookies("goupdates").path = "/"

' Expires after a month
Response.Cookies("goupdates").Expires = DateAdd("m",1,now())
Server.Transfer("index2.htm")
end if

' Go to default site if nothing checked
if Request.QueryString("show") = "" and Request.Cookies("goupdates") = "TRUE"
then
Server.Transfer("index2.htm")
end if

RadarBob
10-02-2002, 03:43 AM
I guess my reply to your other thread was no help. Sorry. http://www.codingforums.com/showthread.php?s=&threadid=7102

You're describing things going on at the client but show us server-side code. Your code is Active Server Pages stuff which is executed only on the server. You're not there! You're "with the user" clicking on a checkbox on the web page - i.e. the client-side.

First, go to one of the many javascript web sites and get some cookie code. There must be some around. Creating a cookie, deleting a cookie etc.

Then you need to write a javascript function that's triggered by the onclick event for your checkbox. This function will save (or not) the cookie depending on the state of the checkbox. I think I showed you a good outline for that in the other thread.

Then your second web page must look for the cookie "on load". If it's there javascript code will re-direct to the desired web site. Otherwise stay with this second web page.

You don't have to do anything server side for this that I'm aware of.

This makes sense to me. If I'm leading Wobbler astray, someone tell me. I can take it.