...

View Full Version : Setting Cookies



terp_in_umcp
04-09-2007, 06:11 PM
Hi there...

Here's the situation...

There's a sql insert that should run the first time that the user visits a page. If the user just hits refresh then the sql should not run....

I am doing this, but it does not seem to work...it keeps running the sql everytime...am I even using the right logic? Any ideas???

if Request.Cookies("visited")= "yes" then

else

(sql insert statement here)

Response.Cookies("visited")="yes"

end if

ess
04-09-2007, 07:27 PM
First of all, check that your browser allows cookies to be set etc.

Second, you should specify duration under which the cookie will expire. For example, a day, a month, a year, etc.

how about the following.

if Request.Cookies("visited")= "yes" then

else

(sql insert statement here)

Response.Cookies("visited")="yes"
'expires after a year
Response.Cookies("visited").Expires=#09 April 2009 11:18:21#
Response.Redirect "http://www.YOUR_WEBSITE_ADDRESS.com"
end if

terp_in_umcp
04-09-2007, 10:56 PM
Thanks that worked!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum