You use the session data of the current user as the name but the sender actually isn't the current user. Perhaps you can send the username and the message together to the server?
handleResponse: function(response)
{
$('chat_id_box').innerHTML += '<u class="myId">'+response.user+'</u>: <p class="talk">'+response.msg+'</p></br>';
}
Update
Although this is a little bit late, you can encode your data into JSON. Then, when you use it, you can decode it.
<?php
$response = json_decode(file_get_contents($filename));
$response->timestamp = $currentmodif;
echo json_encode($response);
flush();
When you write message to the file, you can use this:
<?php
file_put_contents($filename,json_encode(array('msg'=>$msg,'name'=>$name)));