SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2002
    Location
    Chester UK
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Managing Users with PHP Sessions and MySQL Tutorial

    Hello people,

    Just signed up to this forum, and by about 2pm tomorrow you will all be sick and tired of me

    I am fairly new to PHP but have bought a couple of books to help me along the road.

    I stumbled across the Tutorial:Managing Users with PHP Sessions and MySQL.

    I have 1 question at the moment:

    How can I make it so that it sets a cookie and that cookie is valid for say, 24hours?

    If someone could point me in the right direction, that would be appreciated.

    Cheers

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/manual/en/function.setcookie.php

    /* expire in 1 hour */
    setcookie ("TestCookie", $value, time() + 3600);

  3. #3
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The cookie will also be readable in the $HTTP_COOKIE_VARS array.

  4. #4
    Action! filmfoto's Avatar
    Join Date
    Dec 2001
    Location
    Sweden
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As of PHP 4.1 use $_COOKIE instead.

    Does anyone know how long $HTTP_*_VARS, will be supported?

  5. #5
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean?

    $HTTP_COOKIE_VARS will be accessible as long as your cookie is valid. (i.e. not expired)

  6. #6
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh sorry, I totally missed the question

    $_COOKIE is just a short cut for $HTTP_COOKIE_VARS they will both exist, the php guys are trying to promote more secure coding by making it easier to access specific arrays.

  7. #7
    Action! filmfoto's Avatar
    Join Date
    Dec 2001
    Location
    Sweden
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great!

    I thought I had to read through 11563 lines of code and change all $HTTP_*_VARS.

  8. #8
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by filmfoto
    Does anyone know how long $HTTP_*_VARS, will be supported?
    they'll probably be "supported" for awhile (like register_globals, unfortunately ). however, starting with 4.1.0 (when the new arrays were introduced ), $HTTP_*_VARS is (are? ) deprecated. i'll change my scripts over when i feel that enough hosts have upgraded to 4.1.0 or greater (maybe within 6 months, i dunno).
    Last edited by DR_LaRRY_PEpPeR; Jan 16, 2002 at 04:46.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  9. #9
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're working with that tutorial, you may be more intested in functions like session_set_cookie_params as you'll already be using session cookies.


Bookmarks

Posting Permissions

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