SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing Session Via URL

    How do you do it? I've been looking through two of my PHP books and I can't figure out how to place the sessionhash in there.

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    Perth, Australia
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi CeleronXL

    I don't know that you would pass the whole session hash in the url, just a Session ID number for each person, which corresponds to an entry in a database (that's how it works for discussion boards any way) of current users, and all the info is stored there.

    Paul
    Paul Davey
    webmaster for Whitford Church of Christ

  3. #3
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you pass the session id? What URL would you use? (ie. something like index.php?PHPSESSID=$something)

  4. #4
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you need to do that?
    Whatever session var you want to pass, you can just pull it out with the $_SESSION['var'] without passing it as $_GET['var'].

  5. #5
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dtang4, no he is storing the id of the session in the url, normally it is stored inside cookie but obviously not in this example.
    CeleronXL: Yes, you could do that, just make sure you place this on every link on your site!
    - website

  6. #6
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/manual/en/ref.session.php and
    http://www.php.net/manual/en/function.session-id.php

    never done this but I think that the following makes sense :

    You would do session_start(); if you are using that type of session (not a custom one) and the add to all your urls ?sessid=' . SID . '&...
    then at the beginning of the script you would do
    PHP Code:
    if (isset($_GET['sessid']) && !empty($_GET['sessid']))
    session_id($_GET['sessid']); 
    and then do session_start(); and it would recognise it, hope that helps!

    edit: fixed some type errors ...
    - website

  7. #7
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP should add the session variable to your URL's automatically without any special attention. But it generally only does this when cookies are disabled in the browser.

  8. #8
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Phil.Roberts
    PHP should add the session variable to your URL's automatically without any special attention. But it generally only does this when cookies are disabled in the browser.
    Yes, but only if you have that option set or if you compile PHP with that in it.

    Thanks website. [img]images/smilies/smile.gif[/img]
    Last edited by CeleronXL; Jul 14, 2003 at 08:39.
    So hold me when I'm here
    Right me when I'm wrong
    Hold me when I'm scared
    Love me when I'm gone.


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
  •