1 (edited by Blaxus 2010-02-20 12:55)

Topic: PunBB Login Cookie

Hey, i am currenly working on the system for my new website. However i do not feel the need to script my own Forum System and i will be needing a forum system either way.

I have used PunBB before and i like it very much.
I found the integration page which helped me very much, the login works perfectly fine.

I want my registered forum members to be able to view member only pages.
The website i am creating looks like this:

site.com/ - main website running custom script
site.com/forum/ - running punbb. Logging in also sets the cookie for the main domain so i should be able to use it.

I use firefox's web developer toolbar to check whether the cookies are saved and where.
I found that punbb makes 1 cookie but i cannot seem to find out how i can authenticate people with it.

I have a good set of knowledge of php so do not worry to speak what's on your mind.
The cookie contains some kind of hash which might include the username/password/email/id, but i don't really know how how to use it.

So can a developer or punbb user maybe point me in the right direction as to how i can authenticate a user with this cookie?

2 (edited by Blaxus 2010-02-20 13:48)

Re: PunBB Login Cookie

Alright, so searching the forums for a half hour seemed to pay off. I found that information in PunBB 1.3 is passed on using the variable $forum_user, and i managed to check whether or not the currently logged in user is a Guest, User or an Admin.

To see how i did this here is the code:

<?php
// If you want to see what this var prints uncomment it
//echo print_r($forum_user);

// This person is GUEST and NOT ADMIN. (GUEST)
if($forum_user['is_guest'] == 1 && empty($forum_user['is_admmod']))
{
    $login = "Guest";
}
// This person is NOT GUEST and NOT ADMIN (USER)
elseif(empty($forum_user['is_guest']) && empty($forum_user['is_admmod']))
{
    $login = "User";
}
// This person is NOT GUEST and ADMIN (administrator)
elseif(empty($forum_user['is_guest']) && $forum_user['is_admmod'] == 1)
{
    $login = "Admin";
}

echo "Hello ".$login."!";
?>

This allows me to use the code to let my forum users submit and favorite etc on my main website. Currently i do not see a code for checking specificly if the logged in person is a user (which i would prefer). But because i have 2 things i can check it and clearly see who is a user and who is not.

A person who is not logged in or does not have any cookie should be classified as a guest by the forum system so if that is possible to disable i would not reccomend it if you are going to use this system.

Unfortunantly no one helped me but that does not mean i will not help other.
I thank you guys for your time and the great system and i hope you will see my finnished site very soon.

Greetings Blaxus.