Anatoly wrote:

Browser? Cookie settings?

Safari 3.1.2 on Mac OS-X 10.5

Cookie settings to normal ("accept all from sites you navigate to"), never had a cookie problem elsewhere hmm

Actually, I just realized that the "mark as read" link has the same problem.

Uh, I said above: 1.3RC

I realize this is a dev. realease (1.3) so I won't rant.  I just wanted to point out that topics are not properly being marked as read when I read them.

When I read the topic, it IS being marked read, but then I leave the forum for say 1 hour, return and voila, the threads I read are 'unread' again even though there are no new posts there, no edits etc.

Really. Annoying.

Omg, now it works.  Unbeliveable.  Well, just goes to proove that I should learn cookies :S
I've always worked with sessions because I thought original cookies as outdated.  Thanks a lot!

Ok, Ill explain it a little simpler. Sometimes it helps to cut all the un-needed crap away and make the problem as simple as it can be.  I have done that now.

Forget everything I said above and look at this code placed inside the forum dir called "login2.php":

<?php

define('PUN_ROOT', './');
global $db, $pun_user, $pun_config;
require PUN_ROOT.'include/common.php';

$userid = 2;
$pass = pun_hash("none");
pun_setcookie ($userid, $pass, 86400);

?>

I go to login2.php and get no errors whatsoever.  I then return to index.php of the forum, and SHOULD be logged in, however I'm not logged in.  What am I doing wrong? Userid "2" and hashpassword "71f8e7976e4cbc4561c9d62fb283e7f788202acb" are correct values, I checked via phpmyadmin.

Well, it displays "You are not logged in."

What does $pun_user have to do with logging people in?  I fail to see the connection here.  What else must I do apart from setting the cookie with pun_setcookie(); ?

What's pun_user, and why would I need to change it?  I mean setting the login cookie should be enough, shoulnt it?

Also, could it have something to do with where the punBB cookie it set? At which path?
I'm setting it in the root dir (domain.com/login.php) and my forum is in domain.com/forum/

In short I want to use my existing log in script to also log users into punBB automatically.
I'm using the following code:

define('PUN_ROOT', './forum/');
global $db, $pun_user, $pun_config;
require PUN_ROOT.'include/common.php';

pun_setcookie ('2', '71f8e7976e4cbc4561c9d62fb283e7f788202acb', '86400');

It even adds the username of the userid "2" to the "online" list. That proves that the userid and passwordhash are correct.  However, I am not being logged in.  There are no errors whatsoever, its setting the cookie, that much is for sure, but for some reason punBB tells me I'm not logged in.

I'm sure others have run into this problem...can anyone help me?

Yep, that worked perfectly.  For anyone who's interested in this (rather simple code) to log people in, here it is:

$result_pun = mysql_query("select `id` from `f_users` where `username`='$username' ");
$row_pun = mysql_fetch_array($result_pun);
pun_setcookie ($row_pun['id'], pun_hash($origpassword), time() + 86400);

and the logout looks like this:

setcookie('punbb_cookie', "", 31536000, "/");
mysql_query(" DELETE FROM `f_online` WHERE `user_id`='$userid' ");
$ctime = time();
mysql_query(" UPDATE `f_users` SET `last_visit`='$ctime' WHERE `id`='$userid' ");

edit: it turns out that the above code only worked on my offline server.  On a real server/domain, its punBB doesnt recognize the cookie :S

How exactly would I go about logging a user into punBB?  It uses cookies, not sessions, I havent worked with those before.

EDIT: After looking at several posts here and the include/functions.php file I still don't understand.  I have to use " pun_setcookie($user_id, $password_hash, $expire);" to log people in?

Hmm, okay, you've convinced me.

Yeah, I thought about that, but it seems a bit ineffcient and edgy from a programmers point of view.

I would like punBB to use the information from an existing table in the DB for username/password.  Basically people have registered on a game I have programmed, and now that Im adding forums I dont want them to have to re-register.  Is this possible without a whole lot of re-writing and editing? If so, please tell me how.

Help is rally appreciated!