Empty Session Variables in templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RZAmber
    New Member
    • Oct 2006
    • 10
    • 3.5.x

    Empty Session Variables in templates

    Looking for assistance with the header template.

    The session vars in bold are not initialized for the header template but the call to these vars in other templates called after the header ARE getting values for these session vars.

    These session vars being empty is causing the remember me area in the header to show as the login form even when a user is logged in, instead of showing the welcome statement, number of private messages, etc.

    See bolded below:

    <table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td class="border">
    <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <a name="top"></a>
    <td width="59%" class="bg01">&nbsp;</td>
    <td width="41%" class="bg02">&nbsp;</td>
    </tr>
    </table>
    <!-- logo -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td width="122" valign="top" class="white"><if condition="$show['member']"><a href="usercp.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/usercp.gif" border="0" alt="User CP"></a></if><if condition="$show['registerbutton']"><a href="register.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/register.gif" border="0" alt="Register"></a></if><br />
    <if condition="$show['popups']">
    <a href="#usercptools" id="usercptools"><img src="$stylevar[imgdir_misc]/quicknav.gif" border="0" alt="Quick Nav"></a><script type="text/javascript"> vbmenu_register("usercptools", true); </script></if><br /><a href="memberlist.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/memberlist.gif" border="0" alt="Member List"></a><br />
    <a href="calendar.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/memcalendar.gif" border="0" alt="Calendar"></a><br />
    <a href="search.php?$session[sessionurl]" accesskey="4"><img src="$stylevar[imgdir_misc]/commsearch.gif" border="0" alt="Search"></a>
    <br /><if condition="$show['member']"><a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]" onclick="return log_out()"><img src="$stylevar[imgdir_misc]/logout.gif" border="0" alt="Log Out"></a></if></td>
    <td width="164" class="logobg">$random_banner[$random_number]</td>
    <td width="114" class="logobg">&nbsp;</td>
    <td width="100%" class="logobg">
    <if condition="$bbuserinfo['userid']">


    <div class="smallfont">
    <!--<span style="float:$stylevar[right]">[<a href="login.php?$session[sessionurl]do=logout&amp;u=$bbuserinfo[userid]" onclick="return log_out()">$vbphrase[log_out]</a>]</span>-->
    <strong><phrase 1="$bbuserinfo[username]">$vbphrase[welcome_x]</phrase></strong><br />
    <phrase 1="$pmbox[lastvisitdate]" 2="$pmbox[lastvisittime]">$vbphrase[last_visited_x_at_y]</phrase>
    <if condition="$show['pmstats']"><br /><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl]">$vbphrase[private_messages_nav]</phrase></if>
    </div>

    <else />

    <!-- login form -->
    <form action="login.php" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
    <script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
    <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
    <tr>
    <td class="smallfont"><label for="navbar_username">$vbphrase[username]</label></td>
    <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
    <td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
    </tr>
    <tr>
    <td class="smallfont"><label for="navbar_password">$vbphrase[password]</label></td>
    <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" accesskey="p" tabindex="102" /></td>
    <td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
    </tr>
    </table>
    <input type="hidden" name="s" value="$session[sessionhash]" />
    <input type="hidden" name="do" value="login" />
    <input type="hidden" name="vb_login_md5password" />
    <input type="hidden" name="vb_login_md5password_utf" />
    </form>
    <!-- / login form -->
    </if>
    </td>
    </tr>
    </table>
    <!-- /logo -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <a name="top"></a>
    <td width="100%" class="bg03">&nbsp;</td>
    </tr>
    </table>
    <if condition="$show['member']">
    <!-- user cp tools menu -->
    <div class="vbmenu_popup" id="usercptools_menu" style="display:none">
    <table cellpadding="4" cellspacing="1" border="0">

    <tr><td class="thead">$vbphrase[quick_links]</td></tr>
    <if condition="$vboptions['enablesearches']"><tr><td class="vbmenu_option"><a href="search.php?$session[sessionurl]do=getnew">$vbphrase[new_posts_nav]</a></td></tr></if>
    <tr><td class="vbmenu_option"><a href="forumdisplay.php?$session[sessionurl]do=markread">$vbphrase[mark_forums_read]</a></td></tr>
    <tr><td class="vbmenu_option"><a href="#" onclick="window.open('misc.php?$session[sessionurl]do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,r esizable=yes,width=250,height=300'); return false;">$vbphrase[open_buddy_list]</a></td></tr>

    <tr><td class="thead"><a href="usercp.php?$session[sessionurl]">$vbphrase[user_control_panel]</a></td></tr>
    <if condition="$show['siglink']"><tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=editsignature">$vbphrase[edit_signature]</a></td></tr></if>
    <if condition="$show['avatarlink']"><tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=editavatar">$vbphrase[edit_avatar]</a></td></tr></if>
    <tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=editprofile">$vbphrase[edit_profile]</a></td></tr>
    <tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=editoptions">$vbphrase[edit_options]</a></td></tr>
    <tr><td class="vbmenu_option"><a href="member.php?$session[sessionurl]u=$bbuserinfo[userid]">$vbphrase[my_profile]</a></td></tr>

    <tr><td class="thead">$vbphrase[miscellaneous]</td></tr>
    <if condition="$show['pmstats']"><tr><td class="vbmenu_option"><a href="private.php?$session[sessionurl]">$vbphrase[private_messages]</a></td></tr></if>
    <tr><td class="vbmenu_option"><a href="subscription.php?$session[sessionurl]">$vbphrase[subscribed_threads]</a></td></tr>
    <tr><td class="vbmenu_option"><a href="donate.php?$session[sessionurl]">$vbphrase[donate]</a></td></tr>
    <tr><td class="vbmenu_option"><a href="<A href="http://www.realzetas.com/gallery/">RZ">http://www.realzetas.com/gallery/">RZ Gallery</a></td></tr>
    <tr><td class="vbmenu_option"><a href="arcade.php?$session[sessionurl]">RZ Arcade</a></td></tr>
    <tr><td class="vbmenu_option"><a href="vbplaza.php?$session[sessionurl]">RZ Store</a></td></tr>
    <tr><td class="vbmenu_option"><a href="journal.php?$session[sessionurl]">$vbphrase[journal]</a></td></tr>
    <if condition="$show['wollink']"><tr><td class="vbmenu_option"><a href="online.php?$session[sessionurl]">$vbphrase[whos_online]</a></td></tr></if>

    </table>
    </div>
    <!-- / user cp tools menu -->
    </if>
    <!-- content table -->
    $spacer_open
    $_phpinclude_output
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    Those session variables are only defined for users whose browsers don't support cookies. Otherwise the session info is passed via cookie. More often than not, that variable contains no value.

    $bbuserinfo[logouthash] is defined for all logged in users and does work in the header. The same goes for $bbuserinfo[userid]. I have confirmed this on my test forum.

    Comment

    • RZAmber
      New Member
      • Oct 2006
      • 10
      • 3.5.x

      #3
      oh Im not saying they dont work for the message board in general Im saying they arent working for me right now.

      It was working a few days ago, trying to figure out why it stopped working.

      I recently changed the home page of the forum from index.php to index2.php and modified the file functions_login.php to redirect to index2.php upon login, because I added a new homepage not related to vbBulletin, and named this index.php instead.

      I have since rolled those changes back to see if maybe $bbuserinfo[userid] and $bbuserinfo[logouthash] are dependent on the home page being named index.php

      For my message board right now, code below is not working when users are logged in..$bbuserinfo['userid'] is not returning a value causing the else statement to occur, displaying the login form, even if a user is logged in.

      Just looking for help as to what could be the cause...

      <if condition="$bbuserinfo['userid']">


      <div class="smallfont">
      <!--<span style="float:$stylevar[right]">[<a href="login.php?$session[sessionurl]do=logout&amp;u=$bbuserinfo[userid]" onclick="return log_out()">$vbphrase[log_out]</a>]</span>-->
      <strong><phrase 1="$bbuserinfo[username]">$vbphrase[welcome_x]</phrase></strong><br />
      <phrase 1="$pmbox[lastvisitdate]" 2="$pmbox[lastvisittime]">$vbphrase[last_visited_x_at_y]</phrase>
      <if condition="$show['pmstats']"><br /><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl]">$vbphrase[private_messages_nav]</phrase></if>
      </div>

      <!-- login form -->
      <form action="login.php" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
      <script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
      <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
      <tr>
      <td class="smallfont"><label for="navbar_username">$vbphrase[username]</label></td>
      <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
      <td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
      </tr>
      <tr>
      <td class="smallfont"><label for="navbar_password">$vbphrase[password]</label></td>
      <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" accesskey="p" tabindex="102" /></td>
      <td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
      </tr>
      </table>
      <input type="hidden" name="s" value="$session[sessionhash]" />
      <input type="hidden" name="do" value="login" />
      <input type="hidden" name="vb_login_md5password" />
      <input type="hidden" name="vb_login_md5password_utf" />
      </form>
      <!-- / login form -->
      </if>

      Comment

      • Jake Bunce
        Senior Member
        • Dec 2000
        • 46598
        • 3.6.x

        #4
        The $bbuserinfo[] works fine in the header template. I have confirmed this on my test forum.

        Your code seems to be displaying a login form for logged in users which doesn't make sense. Surely you meant to use !$bbuserinfo[userid] for the condition?

        Comment

        • RZAmber
          New Member
          • Oct 2006
          • 10
          • 3.5.x

          #5
          Actually I entered the code wron. Forgot the else statement.

          But Im sure it does work for you on your test forum.

          Im trying to get help about my specific situation.

          On my board $bbuserinfo['userid'] is not returning true.

          If it were, the else statement would not be occuring.

          Can you tell me if there is any reason you know of why this would be coming back as false?

          I was suspecting may be because I renamed the index page.

          Or could there be something missing in an includes file that it depends on that would cause this var not to initiate.

          Im just trying to seee if my changes effected this var.

          I made my changes and 4 days later this problem started ocurring.

          Maybe I deleted something in the template by mistake when editing it?






          <if condition="$bbuserinfo['userid']">


          <div class="smallfont">
          <!--<span style="float:$stylevar[right]">[<a href="login.php?$session[sessionurl]do=logout&amp;u=$bbuserinfo[userid]" onclick="return log_out()">$vbphrase[log_out]</a>]</span>-->
          <strong><phrase 1="$bbuserinfo[username]">$vbphrase[welcome_x]</phrase></strong><br />
          <phrase 1="$pmbox[lastvisitdate]" 2="$pmbox[lastvisittime]">$vbphrase[last_visited_x_at_y]</phrase>
          <if condition="$show['pmstats']"><br /><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl]">$vbphrase[private_messages_nav]</phrase></if>
          </div>

          <else />

          <!-- login form -->
          <form action="login.php" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
          <script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
          <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
          <tr>
          <td class="smallfont"><label for="navbar_username">$vbphrase[username]</label></td>
          <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
          <td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
          </tr>
          <tr>
          <td class="smallfont"><label for="navbar_password">$vbphrase[password]</label></td>
          <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" accesskey="p" tabindex="102" /></td>
          <td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
          </tr>
          </table>
          <input type="hidden" name="s" value="$session[sessionhash]" />
          <input type="hidden" name="do" value="login" />
          <input type="hidden" name="vb_login_md5password" />
          <input type="hidden" name="vb_login_md5password_utf" />
          </form>
          <!-- / login form -->
          </if>
          Last edited by RZAmber; Wed 11 Oct '06, 6:24pm.

          Comment

          • RZAmber
            New Member
            • Oct 2006
            • 10
            • 3.5.x

            #6
            Are there any setting in the admincp, that if changed would cause the
            $bbuserinfo vars to not return values?

            Comment

            • Jake Bunce
              Senior Member
              • Dec 2000
              • 46598
              • 3.6.x

              #7
              Start from the bottom up... test the base condition:

              Code:
              <if condition="$bbuserinfo[userid]">
              	I AM LOGGED IN
              </if>
              Enter this code into your template. When you are logged in does it show the debug text, "I AM LOGGED IN"? It should. If it doesn't then your forum is not functioning properly. Try uploading the original PHP files and disabling your plugins to revert all code back to default.

              Comment

              • RZAmber
                New Member
                • Oct 2006
                • 10
                • 3.5.x

                #8
                Yeah it actually doesnt show that. Which would suggest that
                for that template it is seeing the user as not logged in

                but other templates that follow after the call to header seem to pick up the
                user as logged in just fine.

                For example, my template for navigation uses the same user vars and is called immediately after the header template.

                The forum is working fine its just that one header template.

                Any other suggestions besides staring from scratch?

                Comment

                • Jake Bunce
                  Senior Member
                  • Dec 2000
                  • 46598
                  • 3.6.x

                  #9
                  If it works on a vanilla forum, then you know that a customization is to blame. At that point you need to systematically troubleshoot your customizations to isolate the culprit.

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...