Problem customising content for logged-in users

Discussion in 'Customization & add-ons' started by harthacanute, Aug 14, 2007.

  1. harthacanute

    harthacanute New Member

    Joined:
    Feb 25, 2007
    Messages:
    14
    Hello there.

    I'm trying to customise a page so that the content is different for members who have logged in. However, there's a problem.

    The script I use to check this is:

    session_start();
    $user = $_SESSION['_amember_user'];
    if ($user['member_id'] > 0){
    print "You are logged in";
    } else {
    print "You are not logged-in.";
    }

    The script is placed on non-protected php pages.

    I previously logged in, and clicked on the 'remember' box.

    If I open the browser, and go to the non-protected page with this script, it says I'm not logged in. However, I am logged in: I can access protected pages, and the amember/member.php without logging in again.

    This script only says I'm logged in, if I have viewed either a protected page, or if I have gone to amember/member.php.

    Is there any way of checking to see if I'm logged in without going to either of these pages?

    Any assistance is very much appreciated!
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Include to top of your PHP page:

    <?php
    require_once '/home/user/public_html/amember/plugins/protect/php_include/reload_if_cookie.inc.php';

    If your aMember does not have this file, contact us via helpdesk.
  3. harthacanute

    harthacanute New Member

    Joined:
    Feb 25, 2007
    Messages:
    14
    Yes - I'm missing this file. I'll contact you as you advise.

    Thanks.

Share This Page