Missing session data aMember 4.

Discussion in 'Customization & add-ons' started by pcgaming, Jul 20, 2012.

  1. pcgaming

    pcgaming New Member

    Joined:
    Mar 28, 2012
    Messages:
    23
    We have a several static pages within a new rewrite folder that we need to get the users email address and name for. However, it would appear that even though the user can still access the folder contents, implying they are still logged in, when I go to grab the session data, it is missing.

    For example, my folders structure is like this:

    /protected-folder
    /protected-folder/apply/index.php <-- we need email and name for index.php

    Code used:
    Code:
    session_start();
    if (empty($_SESSION['amember_auth']) ||
        empty($_SESSION['amember_auth']['user']['user_id'])) {
        header("Location: /amember/login/");
        exit;
    }
    $userMailAddress = $_SESSION['amember_auth']['user']['email'];
    
    What happens, if the user logs in, then apply/index.php works fine for a very short period of time. Then if the user goes back to apply/index.php 20 minutes later, they are redirected to the login page. But if they go to other places within /protected-folder/ that don't check for session data, they are fine.
    Is there a way to get around this? Am I trying to load the users name and email incorrectly?
    Thank you.
  2. pcgaming

    pcgaming New Member

    Joined:
    Mar 28, 2012
    Messages:
    23
    Small update:

    Now using this:
    Code:
    <?php
    include ('path/to/Am/Lite.php');
    if (!Am_Lite::getInstance()->isLoggedIn()) {
        header("Location: " . Am_Lite::getInstance()->getLoginURL($_SERVER['REQUEST_URI']));
        exit;
    }
    
    Not logged out yet, but I will see what happens in 20 minutes.

Share This Page