SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    passing session_id thru url

    Plz somecome tell me , how to pass session_id with the url in the flwg syntax

    $lines = file('http://localhost/clinical/hair/hirsutism/');

    foreach ($lines as $line_num => $line) {
    echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
    }

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I don't see how the code you posted relates in any way to URLs, sessions, or IDs. Please clarify.

    http://www.example.com/script.php?id=1 will populate $_GET['id'] with the value 1.

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am able to fetch a variable with the query string but not session..

    The url http://localhost/clinical/hair/hirsutism is SEO for the flwg :

    http://localhost/clinical/hair.php?art=hirsutism
    and I am able to read the fiel with the posted code

    my prob is:
    hair.php has session conditions as given below
    <body>
    <?php
    $art = $_REQUEST['art'];

    if($art == "hirsutism"){
    if($_SESSION['user_id']){

    echo "a";

    }
    else{
    echo "b";
    }
    }
    ?>
    </body>
    now when I read the file with
    $lines = file('http://localhost/clinical/hair/hirsutism/');

    I get the content "b", so wht shud I do to read "a"

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    session_start();
    $sid session_name() . '=' session_id();
    session_write_close();
    $url 'http://localhost/clinical/hair/hirsutism/?' $sid
    if your using mod rewrite and werent careful about how you wrote your rewrite rule, it may eliminate the query string, making php not able to see variables passed via GET. in that case, you would either need to correct the rewrite rule, or just use a non rewritten url:

    PHP Code:
    $url 'http://localhost/clinical/hair.php?art=hirsutism&' $sid


    but, is there a reason your doing all of this via a seperate http request? it would make more sense to use a local file include / function to get your values.

  5. #5
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A]
    in case the rewrite rule have eliminated the query string, I wud not have got
    "http://10.0.0.4/idg/clinical/skinapp/hair/hirsutism/" for
    "http://10.0.0.4/idg/hair.php?art=hirsutism"


    anyway the rule I've written is
    RewriteRule clinical/hair/([a-zA-z]+)/([a-zA-z|-]+)$ /hair/$1/$2/ [R=301,L]
    RewriteRule clinical/hair/([a-zA-z]+)/([a-zA-z|-]+)/$ /hair/$1\.php?art=$2

    do I need to chg the above rule and where exactly


    B]
    "it would make more sense to use a local file include / function to get your values." =>

    how 2 do this, I am accessing the urlpath to be read thru database
    $lines = file($url);

  6. #6
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx clamcrusher,
    it did work with
    $url = 'http://localhost/clinical/hair.php?art=hirsutism&' . $sid;


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
  •