Sessions not passing properly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Fitzgerald

    Sessions not passing properly

    I use sessions as part of my login script. One of the values passed is
    userid. The userid seems to pass fine into the main part of the page,
    but when I use userid in a navigation include I cannot get it to
    display.

    Here' what I mean.

    Code for admin navigation:

    function adminMenu(){
    echo $userid;
    @$result = mysql_query("SE LECT menuid,menulabe l,menuname,url, parent
    from crc1.tbluspmatr ix u, crc1.tblmenu
    m where
    u.privid = m.priv_id and u.userid =
    '$userid'
    AND parent = '0' AND module_id = '1'
    AND
    view= '1' AND position='0' ORDER BY
    lorder
    ASC");
    @$counter = 0;
    while ($row = mysql_fetch_arr ay($result)){
    $path = $_SERVER['PHP_SELF'];
    @$class = ( $row['url'] == $path ? 'td_select' : 'td_root' );
    echo '<td width=" " valign="top" class="'.$class .' "
    style="border-right-width:
    1px;border-left-width:
    0px;border-top-width: 0px;border-bottom-width:
    0px;border-
    color: white; border-style: inset;vertical-
    align:middle;"> <a id="a_root_'.$c ounter.'"
    border="0"
    style="cursor:h and; text-align:top;"> <a

    class="'.$class .'"onMouseover= "this.style.col or=\'black\'"
    onMouseout="thi s.style.color=\ 'white\'"
    onMouseout="thi s.style.color=\ 'white\'" href="'.$row
    ['url'].'">'.$row['menuname'].'</a> </td>';
    }//end while

    return;
    }
    ?>

    I tried echoing out the $userid value, but it did not work. The page
    that this include is included in does have session_start() at the top.
    I even tried using session_start() at the beginning of the above
    function, but that did not work. As I said earlier in the post, the
    userid does seem to pass properly to the page mycrc.php, but not to
    the adminmenu_func. inc (which is included in mycrc.php).

    Any ideas?
  • RG

    #2
    Re: Sessions not passing properly


    "Steve Fitzgerald" <sf@mnetsys.com > wrote in message
    news:f1885463.0 306300237.58dcc cc7@posting.goo gle.com...[color=blue]
    > I use sessions as part of my login script. One of the values passed is
    > userid. The userid seems to pass fine into the main part of the page,
    > but when I use userid in a navigation include I cannot get it to
    > display.
    >
    > Here' what I mean.
    >
    > Code for admin navigation:
    >
    > function adminMenu(){
    > echo $userid;
    > @$result = mysql_query("SE LECT menuid,menulabe l,menuname,url, parent
    > from crc1.tbluspmatr ix u, crc1.tblmenu
    > m where
    > u.privid = m.priv_id and u.userid =
    > '$userid'
    > AND parent = '0' AND module_id = '1'
    > AND
    > view= '1' AND position='0' ORDER BY
    > lorder
    > ASC");
    > @$counter = 0;
    > while ($row = mysql_fetch_arr ay($result)){
    > $path = $_SERVER['PHP_SELF'];
    > @$class = ( $row['url'] == $path ? 'td_select' : 'td_root' );
    > echo '<td width=" " valign="top" class="'.$class .' "
    > style="border-right-width:
    > 1px;border-left-width:
    > 0px;border-top-width: 0px;border-bottom-width:
    > 0px;border-
    > color: white; border-style: inset;vertical-
    > align:middle;"> <a id="a_root_'.$c ounter.'"
    > border="0"
    > style="cursor:h and; text-align:top;"> <a
    >
    > class="'.$class .'"onMouseover= "this.style.col or=\'black\'"
    > onMouseout="thi s.style.color=\ 'white\'"
    > onMouseout="thi s.style.color=\ 'white\'" href="'.$row
    > ['url'].'">'.$row['menuname'].'</a> </td>';
    > }//end while
    >
    > return;
    > }
    > ?>
    >
    > I tried echoing out the $userid value, but it did not work. The page
    > that this include is included in does have session_start() at the top.
    > I even tried using session_start() at the beginning of the above
    > function, but that did not work. As I said earlier in the post, the
    > userid does seem to pass properly to the page mycrc.php, but not to
    > the adminmenu_func. inc (which is included in mycrc.php).
    >
    > Any ideas?[/color]


    You need to pass the userid to the function
    function($useri d)

    Your pages main variables have no scope in a function unless you pass them
    to it.
    Hope this helps
    RG



    Comment

    Working...