AMember Session Variables
From AMember Pro Manual
Contents |
aMember sets number of variables in PHP session, that you can use in your code to get information about logged-in customer. To access these variables from PHP code, you should insert
<?php session_start();
to start of your PHP page, before you do any output. If there is any output or spaces before this code, you will get PHP warnings Cannot send session cookie.
[edit] $_SESSION['_amember_login'], $_SESSION['_amember_pass']
These 2 variables contains username and password of the customer. Password can be plain-text or MD5 of the actual user password. These variables are set automatically once customer is logged-in to aMember.
You can also set these variables in your PHP code, and user will be automatically logged-in to aMember (if values are correct).
[edit] $_SESSION['_amember_user']
This variable contains entire aMember customer record as array as described at Creating_New_Integration_Plugins#Understanding_user_record Understanding User Record. You can output user information as show below:
<?php session_start(); $user = $_SESSION['_amember_user']; if ($user['member_id'] > 0){ print "Hello $user[name_f] $user[name_l] <br>\n"; print "Your E-Mail address is $user[email] <br>\n"; print "Your subscription status is $user[status] <br>\n"; } else { print "You are not logged-in"; }
[edit] $_SESSION['_amember_product_ids']
This variable (array) contains list of Product ID# that current customer is subscribed to (and subscription is paid and non-expired). You can check if customer is subscribed to some product or not with the following code:
<?php session_start(); $need_one_from = array(3,4); if (array_intersect($need_one_from, $_SESSION['_amember_product_ids'])){ print "User is subscribed to product #3 or product #4"; } else { print "User is not subscribed to product #3, nor to product #4"; }
[edit] $_SESSION['_amember_products']
This variable (array) contains list of product records that customer is subscribed to. You can use it to check product settings without loading it from database, or including aMember Pro code.
[edit] $_SESSION['_amember_subscriptions']
This variable (array) contains list of only ACTIVE (paid and not expired, and not future) user subscription records - here you can get information about subscription start, end, amount paid, payment receipt# and other useful information.
