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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts

    question about grabbing a session ID

    Does anyone have any opinions as to whether or not you should use session_id() or $_SESSION['SID'] to get the surrent session id? I only ask because recently I read here that session_register() is not a good way to set session variables and i was wondering if session_id() was also bad for some reason.

    Also, I can't seem to find how long a session id is though I think it might be 32 characters. Can anyone confirm this? Thanks.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i always use the session_id() because
    - it is always set, unlike the SID
    - i don't know the $_SESSION['SID'] --> there are 0 searchresults for it in the manual
    - there is no downside to using it.

    I don't see the relevance with the depreciated session_register() --> should not be used because your code will then only work if register_globals=on , which is certainly for newer installations not always true.

    The standard sessionID is the result of an md5-hash, which always is 32 characters long.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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