SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: session id

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey,
    i am also doing (trying and failing actually) sessions in my php advertising system.

    I saw somewhere that you have to do the following code to pass the session id to the next script:
    (call it, create it as a variable, then you would do on the link: script.php?phpsessid=$phpsessid)

    $phpsessid=session_id( );

    Is this right? Because I have also heard in a few places that it passes the session id automatically..
    I am really stuck on sessions at the moment, so any help would be great.
    Thanks very much.
    -aj

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AJ, you are using PHP4, no??? Once you call session_start();
    at the top of the page the session is initialized, and the variable $PHPSESSID is available to you. Or whatever name is assigned to the session.name directive in your php.ini file. If the user has cookies turned on, then a cookie will be placed on their comp with the value of the session id and a file will be created on the server to hold the serialized session data. It also is the case that the first time you initialize a session the $PHPSESSID doesn't appear to be present it is isn't until the page gets reloaded or you link to another page where you have a session_start() that it will show up if you were trying to print it out.

    The only reason you would need to append the $PHPSESSID to the end of the url is so you could allow people without cookies to use sessions on your site. YOu can compile your PHP with the --enable-trans-sid flag which will automatically append the $PHPSESSID to a url when cookies aren't allowed on a users' computer. Most pre-compiled win binaries have it done for you, but if not its really easy to recompile your own version for Linux.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •