Jump to content


Photo

How to see if a user is already logged in PHPBB?


  • Please log in to reply
4 replies to this topic

#1 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 20 August 2006 - 03:29 PM

Hi, I need to somehow check to see if a user is already logged in to phpbb or not. I am putting a login section to the forums on my main page, but it is always there even if the user is already logged in. If the user is already logged in I want it to say something like, "Hello, *name*. You are already logged in." instead of displaying the input boxes.

Here is the code for the form...
<form action="./#" method="post">
	<table border="0" width="100%">
		<tr>
			<td width="30%">
				Username:
			</td>
			<td width="70%">
				<input type="text" name="username" style="width: 90%;" />
			</td>
		</tr>
		<tr>
			<td>
				Password:
			</td>
			<td>
				<input type="password" name="password" style="width: 90%;" />
			</td>
		</tr>
		<tr>
			<td></td>
			<td>
				<div align="center">
					<input type="submit" value=" Log in " />
				</div>
			</td>
		</tr>
	</table>
</form>

If anyone can help me with this please do! Thanks.

#2 tippy_102

tippy_102
  • Members
  • PipPipPip
  • Advanced Member
  • 446 posts

Posted 22 August 2006 - 05:44 AM

The phpBB Login integration tutorial:  http://www.phpbb.com...?article_id=143 contains the script you need.
Fur is more actively protested than leather 'cause its easier to harrass rich women than biker gangs.

#3 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 22 August 2006 - 08:49 PM

Hi, I viewed that link and tryed what it said. It didn't work so I searched around for more session id things. Now I modified my code and it still doesn't work :( If someone can help me debug this and make it work please help!

<?
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
$username = $userdata['username'];
$u_logout = 'login.'.$phpEx.'?logout=true&amp;sid=' . $userdata['session_id'];
$u_login = 'login.'.$phpEx.'?amp;sid=' . $userdata['session_id'];
//
// End session management
//

if( $userdata['session_logged_in'] )
{
?>
<table border="0" width="100%" height='65'>
	<tr>
		<td align='center'>
			You are logged in,<br>
			<? echo $username; ?><br><br>
			<a href="<? './forum/'.$u_logout; ?>">Logout</a>
		</td>
	</tr>
</table>
<?
}
else
{
?>
<form action="<? './forum/'.$u_login; ?>" method="post">
	<table border="0" width="100%">
		<tr>
			<td width="30%">
				Username:
			</td>
			<td width="70%">
				<input type="text" name="username" style="width: 90%;" />
			</td>
		</tr>
		<tr>
			<td>
				Password:
			</td>
			<td>
				<input type="password" name="password" style="width: 90%;" />
			</td>
		</tr>
		<tr>
			<td><a href='./forum/profile.php?mode=register'>Register</a></td>
			<td>
				<div align="center">
					<input type="submit" value=" Log in " />
				</div>
			</td>
		</tr>
	</table>
</form>
<? } ?>


#4 tippy_102

tippy_102
  • Members
  • PipPipPip
  • Advanced Member
  • 446 posts

Posted 23 August 2006 - 05:04 AM

What is the cookie path in phpBB? It should be a single forward slash and not /phpBB2/
Fur is more actively protested than leather 'cause its easier to harrass rich women than biker gangs.

#5 Slodge

Slodge
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 September 2006 - 08:51 PM

Use phpbb_fetch_all for that, you can have a login area, latest form post, whois online etc on your main page. http://www.phpbbfetchall.com/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users