Results 1 to 5 of 5

Thread: How do you Create Cookies?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Question

    Hello all. I am new to writing cookies. I have a website and my user registration and log in page work fine. I can limit their session on the site by using a session variable but I now want to use cookies to recognize my registered users and populate various fields automatically so that my site becomes more functional.

    Who can help and show me the code?

    thanks!

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    This should work, double check the Expires property though....

    To write a cookie
    Response.Cookies("MyCookie") = "Hello World!"
    Response.Cookies("MyCookie").Expires = "1/1/2002"

    To read a cookie
    response.write request.cookies("MyCookie")

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Smile

    forgive me for my dumbness but do I insert the

    Response.Cookies("MyCookie") = "Hello World!"
    Response.Cookies("MyCookie").Expires = "1/1/2002"

    AFTER they log in or while they log in?

    And after that where do I place the

    response.write request.cookies("MyCookie") ?

  4. #4
    Banned
    Join Date
    Feb 2000
    Location
    Edmonton, AB, Canada
    Posts
    64
    Jesus4u,

    Check out http://www.w3scripts.com/asp/asp_cookies.asp tutorial for a lesson on ASP cookies.

  5. #5
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Also try this for the cookie expiry date

    Code:
    Response.Cookies("MyCookie").Expires = Date() + 30
    or
    Response.Cookies("MyCookie").Expires = Date() + 60
    to make cookie expire after 30 or 60 days
    rather than entering a dtae cos yo make a typo

    DocZaf
    {;->

Posting Permissions

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



Click Here to Expand Forum to Full Width