Now that I've got a very impressive 4 signup login, I need a way to have the header change to show that a user is logged in. My header consists of a standard PHP template and it has the login links to login to amember. I'd like it to be gone when logged in and replaced by "Welcome, username!" or something like that. As this is external to amember itself and I am not using smarty, what have you guys done to deal with this common issue? Hope it's easily solved....
Awesome... I can't wait. I have really customized the amember login so that it's an extremely impressive front end that integrates the various parts of my site. This part will completely it - thanks for pointing me to the missing final link. The last part will be the question of whether I want to include the Facebook integration I bought and whether it is more pain than pleasure.
Not sure why - I'm getting these errors. I've stuck the sessionstart in the header.php which is what is on line 8. The index.php file includes the header.php and I'm getting this error. Not quite sure why. Not sure - do I need to see whether it has been called by another class already and use an "if not called then include this file" directive in my header.php? Would much appreciate the assistance... almost there! Code: [Tue Nov 16 00:38:14 2010] [error] [client 333.333.333.333] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/myaccount/public_html/directory/index.php:297) in /home/myaccount/public_html/nav/header.php on line 8 [Tue Nov 16 00:38:14 2010] [error] [client 333.333.333.333] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home/myaccount/public_html/directory/index.php:297) in /home/myaccount/public_html/nav/header.php on line 8
Couple of things to check: 1) open the following files and ensure there are no empty spaces / extra carriage returns at the bottom of them. If there are delete them and save the file: /home/myaccount/public_html/directory/index.php /home/myaccount/public_html/nav/header.php 2) Any chance that session is being started through some other part of your website? What are you using for your CMS?
session_start() function call should be before any other html code or php output. Move it to the top of the file.
Unfortunately the error is gone but now I'm finding that the top area does not change if you are logged into certain scripts. It still says the standard login. When I view wordpress, it does show that the user is logged in and shows a logout instead. Doesn't happen in vBulletin. Anyone else have this issue or perhaps can explain what is going on? I am using a common php file so it's not a typo and the code works, just only for WP but not VB.
PHP: <?php if ($au=$_SESSION['_amember_user']){ // user is logged-in print "Hello $au[name_f] $au[name_l]! | "; print "<a href='/amember/logout.php'>Logout</a>"; } else { // user is not logged-in print "<span class='linkstop' style='font-weight:bold;'><a class='t' href='http://www.mysite.com/amember/member.php'>Login</a> <span style='color:#43525B;'>or</span> <a class='t' href='http://www.mysite.com/amember/'>Join</a>"; } ?> This isn't working on general PHP pages (session start is right at the top, first thing) and also not in vbulletin. I'm not sure if session start is there too but I'd certainly need a little help in how to set that part up to make sure it's correct. Additionally, it's difficult to put an amember username/password fields into vbulletin and have it login correctly. It's just not working despite looking at the instructions carefully.
@slinky: for testing, have you tried printing out your $_SESSION values to see if the session is actually being started correctly?
Checking that right now and will report back. MUCH appreciate your helping me get all this off the ground... and then later maybe do funky things.
Apparently it is not working. I get parse errors. This works: print "Hello $au[name_f] $au[name_l]! | "; But it only provides first name and last name - not what I want. I want user name! This gives me a parse error: print "Hello $_SESSION['_amember_user']! | "; and none of the user ones print properly either: $user That is completely blank...
Got it. I don't know if it is old code, this is not in the manual but this is how I got what I wanted -- login is the variable. OK, solved that part PHP: <?php session_start(); $user = $_SESSION['_amember_user']; if ($user['member_id'] > 0){ print "Your name is $user[login] <br>\n"; } else { print "You are not logged-in"; } ?>