$_SESSION['_amember_user'] is empty, why?

Discussion in 'Troubleshooting' started by beejeebers, Oct 13, 2009.

  1. beejeebers

    beejeebers Member

    Joined:
    Sep 14, 2007
    Messages:
    68
    I've read the manual about SESSIONS and using amember's values. I really need to use the "member_id" one, and I know exactly how to get it, but when I do this:

    PHP:
    echo "<pre>";
    print_r($_SESSION);
    echo 
    "</pre>";
    It's blank!

    I'm logged into the site too.

    I've also tried this:

    PHP:
    include ("../amember/plugins/protect/php_include/reload_if_cookie.inc.php");
    HELP?
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Did you put:
    session_start();

    at the top of the page?

    David
  3. beejeebers

    beejeebers Member

    Joined:
    Sep 14, 2007
    Messages:
    68
    Hi David,

    Yes I put that at the top.

    It's very odd. I did move to a new server, but it worked fine on the old one. I asked the tech support on the new one if they put the session variables in some odd place. He said they're in the normal spot.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Can you show exact code that you use?
  5. beejeebers

    beejeebers Member

    Joined:
    Sep 14, 2007
    Messages:
    68
    No prob, here you go: (ignore some of the stuff on the page as I've been trying anything).

    PHP:
    <?php
    session_start
    ();
    include (
    "../amember/plugins/protect/php_include/reload_if_cookie.inc.php");
    $au=$_SESSION['_amember_user'];
    if(
    $au==""){
        
    //include "/home/ppccoach/domains/ppc-coach.com/public_html/amember/plugins/protect/php_include/reload_if_cookie.inc.php";
        //include "/home/ppccoach/domains/ppc-coach.com/public_html/amember/plugins/protect/php_include/reload_if_cookie.inc.php";
        
    $au $_COOKIE['_amember_user'];
    }
    $_SESSION[firstname] = $au[name_f];
    extract($_REQUEST);
    if(!isset(
    $_SESSION['firstname'])){
        include 
    "/amember/plugins/protect/php_include/reload_if_cookie.inc.php";
        
    $_SESSION['firstname'] = $au['name_f'];
        
    $_SESSION['member_id'] = $au['member_id'];
    }

    /*
    echo "<pre>";
    print_r($au);
    echo "</pre>";

    $au=$_SESSION['_amember_user'];
    if($au==""){
        $au = $_COOKIE['_amember_user'];
    }
    $_SESSION[firstname] = $au[name_f];
    extract($_REQUEST);
    if(!isset($_SESSION['firstname'])){
        include ("/amember/plugins/protect/php_include/reload_if_cookie.inc.php");
        
        $_SESSION['firstname'] = $au['name_f'];
        $_SESSION['member_id'] = $au['member_id'];
    }
    echo dirname(__FILE__)."<BR>";
    echo $_SESSION['member_id']." and ".$au['member_id']."<BR>";
    */

    echo "AU<BR>";
    echo 
    "<pre>";
    print_r($au);
    echo 
    "</pre>";
    echo 
    "SESSION<BR>";
    echo 
    "<pre>";
    print_r($_SESSION);
    echo 
    "</pre>";
    echo 
    "COOKIE<BR>";
    echo 
    "<pre>";
    print_r($_COOKIE);
    echo 
    "</pre>";
    echo 
    "REQUEST<BR>";
    echo 
    "<pre>";
    print_r($_REQUEST);
    echo 
    "</pre>";
    echo 
    "amember_nr<BR>";
    echo 
    "<pre>";
    print_r($_REQUEST['amember_nr']);
    echo 
    "</pre>";
    ?>
  6. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    Go back to the beginning and save the following as a file called say variables.

    PHP:
    <?php 
    session_start
    (); 
    ?><pre><?php
    print_r
    ($_SESSION); 
    ?> 
    Now access your site, log in and then in a new window call up the file variables.php and post back what you get. I think your coding is a bit suss just want to check with above.
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Do you have file with that code inside aMember folder? Or in different folder?
    If in different, try to place that fle into ammeber folder and test again.
  8. clee

    clee New Member

    Joined:
    Aug 27, 2008
    Messages:
    14
    I'm having the same problem. Session variables are not available when check.inc.php
    is called. (plugins/protect/php_include/check.inc.php).

    Even more strange, the session cannot be detected anywhere else on the site unless the user visits member.php.

    In my case, I have a login box which displays "hello username...etc" if the user is logged in. If they are logged out, it shows a login form. The problem is if the member doen't have an active subscription, he then appears to be logged out automatically.

    Is this a known bug?
  9. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Can you show what code you use exactly?

Share This Page