I'm running v.4, and have customised my site so that non-amember pages display 'Hello [name] - you are logged in', using Am_Lite::getInstance()->getName() That all works fine, except when restarting the browser. Then it thinks I'm logged out. I am actually logged in - I have clicked on 'remember me', and can access protected content without logging in again. I had this problem in the past with aMember v.2, and it was solved by this line: require_once '../amember/plugins/protect/php_include/reload_if_cookie.inc.php' ... but v.4 doesn't seem to use this system. Currently, I use this at the top of all pages to check if I'm logged in: include "membership/library/Am/Lite.php"; $lite = Am_Lite::getInstance(); if($lite->isLoggedIn()){ ... Can anyone suggest a way to get it to realise that I am logged in without someone having to access the protected content first? Thank you!
require_once '/home/myusername/public_html/amember/library/Am/Lite.php'; Am_Lite::getInstance()->isLoggedIn() checks if user has been authenticated Above from the wiki at http://www.amember.com/docs/API/Lite
Hello - I appreciate the reply. I've tried that, but still have the same problem. Running the script below only produces a 1 (i.e. logged in) if I've accessed some protected content or viewed an aMember page. <?php require_once '/home/someone/public_html/membership/library/Am/Lite.php'; $member = Am_Lite::getInstance()->isLoggedIn() ; echo $member; ?> Any ideas? Thanks!
That function will return 1, 'which equates to True', so is working correct if the visitor is logged on. Otherwise it will return False ('0'). I understood you wanted to check if visitor was logged in which this function will do. What exactly are you trying to achieve?
If I have logged in previously, but closed the browser and reopened it, it returns a zero. But, I am still logged in - I have ticked the 'remember' box, and if I click on a link in the protected area, I don't have to log in, so I am correctly logged in. However, the script above returns a zero. This means if someone returns to my site, they get the message 'You are not logged in.' Actually, they are logged in - and if they click on the login button, they don't need to enter any login ID. Sorry if this sounds rather confusing.