Not reconizing sessions in the template file

Tutorials for <a href="http://www.phpbbstyles.com/viewtopic.php?t=356">eXtreme Styles mod</a> for phpBB 2.0.

Moderator: Moderators

Not reconizing sessions in the template file

Postby socalsupercars on Fri Mar 02, 2007 8:51 pm

I have added a navigation bar using a php include in the overall_header.tpl file.

Code: Select all
<?php include('../_nav.php'); ?>


The include works fine, but I have also within the include file a check if logged in session and it does not work. It always shows the session as being logged in. Any ideas?

Code: Select all
<?php
if( $userdata['session_logged_in'] )
   {
     echo('
<script type="text/javascript" language="JavaScript1.2">
logged in script
</script>
   ');
      }
   else{
      echo('
<script type="text/javascript" language="JavaScript1.2">
logged out script
</script>
      ');
         }
?>
socalsupercars
Registered User
Registered User
 
Posts: 3
Joined: Fri Mar 02, 2007 8:38 pm

Postby PostBot on Fri Mar 02, 2007 9:38 pm

Template files are included inside a function, so to use global variables you have to declare them:
Code: Select all
global $userdata;
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby socalsupercars on Fri Mar 02, 2007 10:15 pm

So I would change this to? :

Code: Select all
# <?php 
# if( global $userdata['session_logged_in'] ) 
#   { 
#      echo(' 
# <script type="text/javascript" language="JavaScript1.2"> 
# logged in script 
# </script> 
#    '); 
#        } 
#    else{ 
#        echo(' 
# <script type="text/javascript" language="JavaScript1.2"> 
# logged out script 
# </script> 
#        '); 
#            } 
# ?>
socalsupercars
Registered User
Registered User
 
Posts: 3
Joined: Fri Mar 02, 2007 8:38 pm

Postby PostBot on Fri Mar 02, 2007 10:21 pm

[code highlight="2"]<?php
global $userdata;

if( $userdata['session_logged_in'] )
{
echo('
<script type="text/javascript" language="JavaScript1.2">
logged in script
</script>
');
}
else{
echo('
<script type="text/javascript" language="JavaScript1.2">
logged out script
</script>
');
}
?> [/code]
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby socalsupercars on Fri Mar 02, 2007 11:20 pm

Awesome. Thank you. I'm still learning and this was a good lesson.


http://www.socalsupercars.com
socalsupercars
Registered User
Registered User
 
Posts: 3
Joined: Fri Mar 02, 2007 8:38 pm


Return to eXtreme Styles mod tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron