Forum

Thread tagged as: Question, Members

Displaying logged in member details on all pages wthin site

Hi, I'd like to display the name of the logged in member across the entire site but when I view different pages I keep getting logged out? All pages have the runtime.php included. Is there anything else that needs to be added to the page to display logged in member details?

Using perch_members 1.2

Jon H

Jon H 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us an example page that logs you out?

Jon H

Jon H 0 points

Logs in first time then when I refresh the page I get asked to login again. Thanks. Note that I've renamed the folder 'perch' to 'cms'.

<?php
session_start();
include('../cms/runtime.php');
?>
<!DOCTYPE HTML>
<html class="no-js">
<head>
<title>Page title</title>
</head>
<body class="">
<div class="body">
  <!-- Start Site Header -->
  <header class="site-header">
    <div class="topbar">
      <div class="container">
        <div class="row">
          <div class="col-md-12 col-sm-6 col-xs-8">
            <h1 class="logo"> <a href="/"><img src="../img/logo_whitetext.png" alt="Logo"></a> </h1>
          </div>
          <div class="col-md-8 col-sm-6 col-xs-4">
            <a href="#" class="visible-sm visible-xs menu-toggle"><i class="fa fa-bars"></i></a> </div>
        </div>
      </div>
    </div>
    <div class="main-menu-wrapper">
      <div class="container">
        <div class="row">
          <div class="col-md-12">
              <?php include('../inc/menu.php'); ?>
          </div>
        </div>
      </div>
    </div>
  </header>
  <!-- End Site Header -->


  <!-- =================================================================================
      Start of page content, change this part only.
    ==================================================================================== -->
  <div class="main" role="main">
    <div id="content" class="content full">
        <div class="container">
            <? if (perch_member_logged_in()) { ?>
                <div class="row margin-30">
                    <div class="col-sm-6">
                        <div class="row margin-30">
                            <div class="col-sm-12">
                                Member content
                            </div>
                        </div>
                    </div>
                </div>
            <? } else { ?>
                <div class="row margin-30">
                    <div class="col-sm-6"><? perch_members_login_form(); ?></div>
                </div>
            <? } ?>
        </div>
    </div>
  </div>
  <!-- =================================================================================
      End of page content.
    ==================================================================================== -->


  <?php include('../inc/footer.php'); ?>
  <a id="back-to-top"><i class="fa fa-angle-double-up"></i></a> </div>
    <script src="/js/jquery-2.0.0.min.js"></script> <!-- Jquery Library Call -->
    <script src="/plugins/prettyphoto/js/prettyphoto.js"></script> <!-- PrettyPhoto Plugin -->
    <script src="/js/helper-plugins.js"></script> <!-- Plugins -->
    <script src="/js/bootstrap.js"></script> <!-- UI -->

</body>
</html>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there a reason to call session_start() ?

Jon H

Jon H 0 points

I've tried with and without. Makes no difference.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Best without.

So are you saying that even when you log in successfully, you're always logged out? If so, what tells you that you've logged in successfully?

Do the example pages that come with the app work as you'd expect?

Jon H

Jon H 0 points

Yes, each time I refresh the page or view a different page on the site I get logged out? I've removed the session_start() from every page.

I use php to display links in the footer of each page...

<? if (perch_member_logged_in()) { ?>
    <a href="/users/logout.php">Logout</a>
<? } else { ?>
    <a href="/users/login.php">Login</a>
<? } ?>

Strange? After re-running the example pages and removing the session_start() code all seems fine? Are the pages cached in Perch?

Drew McLellan

Drew McLellan 2638 points
Perch Support

The pages aren't cached, no.