Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Setting Cookies

  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting Cookies

    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

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks that worked!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •