Professional Web Applications Themes

Sessions not passing properly - PHP Development

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("SELECT menuid,menulabel,menuname,url,parent from crc1.tbluspmatrix 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_array($result)){ $path = $_SERVER['PHP_SELF']; ...

  1. #1

    Default 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("SELECT menuid,menulabel,menuname,url,parent
    from crc1.tbluspmatrix 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_array($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_'.$counter.'"
    border="0"
    style="cursor:hand; text-align:top;"> <a

    class="'.$class.'"onMouseover="this.style.color=\' black\'"
    onMouseout="this.style.color=\'white\'"
    onMouseout="this.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?
    Steve Fitzgerald Guest

  2. #2

    Default Re: Sessions not passing properly


    "Steve Fitzgerald" <sfmnetsys.com> wrote in message
    news:f1885463.0306300237.58dcccc7posting.google.c om...
    > 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("SELECT menuid,menulabel,menuname,url,parent
    > from crc1.tbluspmatrix 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_array($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_'.$counter.'"
    > border="0"
    > style="cursor:hand; text-align:top;"> <a
    >
    > class="'.$class.'"onMouseover="this.style.color=\' black\'"
    > onMouseout="this.style.color=\'white\'"
    > onMouseout="this.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?

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

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



    RG Guest

Similar Threads

  1. Replies: 6
    Last Post: October 30th, 06:29 PM
  2. Passing SESSIONS with trans_sid switched off
    By Paul in forum PHP Development
    Replies: 6
    Last Post: August 18th, 10:08 PM
  3. #24810 [Fbk->Csd]: sessions not overwritten properly
    By dkaplan1 at uiuc dot edu in forum PHP Development
    Replies: 0
    Last Post: July 28th, 03:44 PM
  4. #24810 [NoF->Fbk]: sessions not overwritten properly
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: July 27th, 06:52 PM
  5. #24810 [NEW]: sessions not overwritten properly
    By dkaplan1 at uiuc dot edu in forum PHP Development
    Replies: 0
    Last Post: July 25th, 09:31 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139