Jump to content

random logouts


envexlabs

Recommended Posts

Hey,

 

I've got an amember problem, and i thought maybe someone here could help me seeing as the support over at amember is excruciating.

 

For some reason i'm getting logged out randomly when surfing my site.

 

I only use amember to deal with payments, signups and logins. I've used session_start() at the top of each page, and each page has the correct session variables.

 

Anyone have any idea?

 

Thanks,

 

envex

 

Link to comment
https://forums.phpfreaks.com/topic/72678-random-logouts/
Share on other sites

Hey,

 

It doesn't happen on specific pages, and it usually happens shortly after i've logged in.

 

The login.php code is:

 

include('./config.inc.php');
$t = & new_smarty();
$_product_id = array('ONLY_LOGIN');

if (isset($_REQUEST['amember_redirect_url']))
    $_SESSION['amember_redirect_url'] = $_REQUEST['amember_redirect_url'];

function rcmp_begin_date($a, $b){
    return strcmp($b['begin_date'], $a['begin_date']);
}

include($config['plugins_dir']['protect'] . '/php_include/check.inc.php');
$payments = & $db->get_user_payments(intval($_SESSION['_amember_id']), 1);
usort($payments, 'rcmp_begin_date');

$now = date('Y-m-d');
$urls = array();
foreach ($payments as $k=>$v){
    if (($v['expire_date'] >= $now) && ($v['begin_date'] <= $now)) {
        $p = get_product($v['product_id']);
        $url = $p->config['url'];
        if (strlen($url)){
            $urls[] = $url;
        }
    }
}

if ($_SESSION['amember_redirect_url']) {
        $redirect = $_SESSION['amember_redirect_url'];
        unset($_SESSION['amember_redirect_url']);
} elseif (count(array_unique($urls)) == 1){
    if (in_array('htpasswd_secure', $plugins['protect'])){
        $member_login_pw = 
        htpasswd_secure_get_login($_SESSION['_amember_user']['login']).
        ':'.
        htpasswd_secure_get_passwd($_SESSION['_amember_user']['pass']);
        $redirect = add_password_to_url($urls[0], $member_login_pw);
    } else {
        if ($config['display_member_pw_urls']) {
             $member_login_pw = 
             $_SESSION['_amember_user']['login'].
             ':'.
             $_SESSION['_amember_user']['pass'];
             $redirect = add_password_to_url($urls[0], $member_login_pw);
        } else {
            $redirect = add_password_to_url($urls[0]);
        }
    }
} else {
    $redirect = "/index.php";
}
#print_r($urls);
html_redirect("$redirect", 0, 'Redirect', _LOGIN_REDIRECT);

Link to comment
https://forums.phpfreaks.com/topic/72678-random-logouts/#findComment-366443
Share on other sites

Unlisted will use the default value.  But you can set it if you want, it won't hurt.

 

If you make a simple session page which does nothing at all and refresh it a few times, does that work?  This is just to verify that sessions are in fact working properly.  After that, you can get to looking at why your code in particular isn't working with sessions.  The problem may be hidden in an include() somewhere, or in one of those functions you call.

Link to comment
https://forums.phpfreaks.com/topic/72678-random-logouts/#findComment-366647
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.