Jump to content

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


hlstriker

Recommended Posts

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...
[code]<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>[/code]

If anyone can help me with this please do! Thanks.
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!

[code]<?
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>
<? } ?>[/code]
  • 2 weeks later...

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.