Private chat, Message logging to mysql DB and Session retaining
I implemented a private chat and is working fine. It is implemented like mentioned here https://github.com/ratchetphp/Ratchet/issues/261. 
This is my current implementation
1) User register in my app with a username.
2) User login (1st and 2nd step through core php)
3) Once user logged in successfully
    a) opens the web socket connection
    b) then send a message containing his username
    c) this username and his resourceId is send to all other online users (notification) 
    d)their UI is updated to reflect the new user.
    e) New user UI is updated with all other users too
        f) When he select a user and send the message it will be delivered to the selected user only.
So far working fine. 
But
1) Is this correct way to implement private chat system?
2) What should I do if I want to log the incoming and out going messages to mysql db. (https://github.com/ratchetphp/Ratchet/issues/145 )
3) What should I do to retain the session even if the user refreshed the page. (currently close the connection)
4) How can I use session provider? From the doc http://socketo.me/docs/sessions. Session is getting like $conn->Session->get('name’);
<?php
    // Inside your MyApp class
    public function onOpen($conn) {
        $conn->send('Hello ' . $conn->Session->get('name'));
    }
But from where should I set it like  $session->set('name’)? If you say after login How to do this with session provider ? I know native session will not work?
Please help me :)
