Try doing it as it is done in the Raidersoft or DigiChat modifications because it is more secure. If you use passed parameters
http://www.somesite.com/chat.php?u=someguy etc. without checking what has been passed can allow people that do not belong in your forum to use your resources.
The chat.php should contain the .threads authenticate function to see who is the member. If the user is not authenticated then call the $html->not_right() method with the relevant message. If the user is authenticated you pick up the username and pass it on the relevant field of the chat software.