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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Get and Set Cookies

    Can someone answer this or point me to a source of info? How do you save a cookie to the user's computer and how do you read that cookie when they open the web site?
    Scott Stewart
    Always happy to learn from pros.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP COOKIES

    PHP Code:
    // This goes before the <html> tag

    setcookie('cookiename','cookie info',time()+3600);

    // time() + 3600 is the expiration. time()+3600 would be 1 hour ( 3600 seconds ) 
    That would set a cookie to the users computer, that would last the set time. To display the contents of the cookie, you need to use $HTTP_COOKIE_VARS ( or $_COOKIE )

    PHP Code:

    // an example, set a cookie then get its value

    setcooke('name','matt',time()+300)

    // sets a cookie called name, with a value of matt that lasts 5 minutes.

    echo $_COOKIE['name'];

    // would write matt on to the page. 

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks a lot for the answers.
    Scott Stewart
    Always happy to learn from pros.

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no prob


  •  

    Posting Permissions

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