If someone logs in before visiting the chat page their username is used just as I want it to be. But when someone visits that chat room while not logged in ... they get assigned a random username (as expected) but if the person then logs in after that point the chat program still continues to use the random username. It is as if the program has cached the username and will continue to use it until the cache is cleared or a substantial time passes.
The username is passed via the custom parameters: the text of which follows:
- Code: Select all
<?PHP
$params2 = array();
$params2["title"] = "ChatAway";
$params2["nick"] = "guest".rand(1,10000); // setup the intitial nickname
if(isset($_SESSION['the_account']['username']) && $_SESSION['the_account']['username'] != '') { $params2["nick"] = $_SESSION['the_account']['username']; }
$params2['frozen_nick'] = true;
$params2["isadmin"] = false; // do not use it on production servers ;)
$params2['height'] = '350px';
$params2['clock'] = false;
$params2["serverid"] = md5('fsdkljfsdfsdsdf'); // calculate a unique id for this chat
$chat = new phpFreeChat($params2);
$chat->printChat();
?>
If I rehash the chat window the program will forget about the previous guest username and take the logged in one.
Any way to work around this caching behavior so as to allow for usernames to be changeable after the fact? I don't want people to be able to define their own nicknames so that no one is able to pretend to be someone they are not, which is why I have frozen_nick set.
Thanks in advance.