If you're writing a forum, then you ought to be using SQL anyway.
And if you're writing a forum, you ought to be writing a login/authentication system, which is the right way to count active users. Anything else is guesswork.
If you're not using logins and prefer to guess, at least use session identifiers and record them in the database along with each page request. Count the number of unique identifiers within whatever reasonable timeout period you define.