generating cookie

Discussion in 'PHP' started by promotingspace.net, Feb 22, 2008.

  1. #1
    Hi
    How can I generate a secure cookie that expires in 30 days
    I want to set this cookie for coding an affiliate program
    There are tutorial for setting cookies in different methods but I posted this thread to find the most secure.
    and what should i store in that cookie? user id? username? what's your suggestion?
    thanks
     
    promotingspace.net, Feb 22, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    www.php.net/setcookie

    There are a lot of examples. As for your other question, it doesn't matter I guess, but I'd use the user ID rather than the user name.
     
    nico_swd, Feb 23, 2008 IP
  3. dansgalaxy

    dansgalaxy Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    setcookie('userid', '$USER ID', '(60*60*24*30)', '.YOUR DOMAIN.co.uk', true);
    
    PHP:
    that should do it ;)
     
    dansgalaxy, Feb 23, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    ^ Should, but won't. ;)

    Variables don't go between single quotes. Neither do mathematical expressions.
     
    nico_swd, Feb 23, 2008 IP
  5. dansgalaxy

    dansgalaxy Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    it was done quick to give the idea i missed out the curly braces.. .
     
    dansgalaxy, Feb 23, 2008 IP