how to make persistant cookie in php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dawgy
    Confirmed User
    • Jul 2001
    • 5856

    #1

    how to make persistant cookie in php?

    i need to make a login thing similar to erasercash.com, so that people can login and choose if they want the cookie to last forever or not... but i cant figure out how to this for some reason. can anyone help me? im already setting a session... but i think thats different?

    thanx
    the revolution is coming.
  • mike503
    Confirmed User
    • May 2002
    • 2243

    #2
    use setcookie() or a header("Set-cookie: ..") without an expiration. or.. with an expiration in 2038 or something. i forget which one it was, heh. php.net/setcookie.

    php/mysql guru. hosting, coding, all that jazz.

    Comment

    • Backov
      Confirmed User
      • Mar 2001
      • 1600

      #3
      Cookies in php are a bit of a pain - the php.net docs are pretty thorough in documenting all the problems (in the user comments).. After screwing with cookies for a while, I started using sessions to maintain user state, although that won't work for something like an affiliate programs cookie..

      Cheers,
      Backov
      <embed src="http://banners.spotbrokers.com/button.swf" FlashVars="clickURL=http://banners.spotbrokers.com" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="120" height="60"></embed>

      Comment

      • Cogitator
        Confirmed User
        • Feb 2002
        • 672

        #4
        Use the SetHeader command above.
        - this space intentionally left blank -

        Comment

        • Cogitator
          Confirmed User
          • Feb 2002
          • 672

          #5
          I mean Header() function. (Wrong programming language...)
          - this space intentionally left blank -

          Comment

          • mike503
            Confirmed User
            • May 2002
            • 2243

            #6
            i set my cookie that never expires like this:

            header("Set-Cookie: id=$id; expires=Friday, 16-Jan-2037 00:00:00 GMT; path=/;");

            $id is a value i assign above. that would be your unique user identifier or something.
            php/mysql guru. hosting, coding, all that jazz.

            Comment

            Working...