I have reading tutorials, mailing lists, and other resources to understand how pre-binding actually works. I have found a few pre-bind scripts with PHP, used it, successfully got the jid, rid, sid
but session always gets lost on page refresh.
I do the prebind on log in, then set the rid, jid, sid
into a session cookie.
After logging in the prebind was successful. I am able to send messages. But on page reload the connection gets lost.
I have understood that on every request the RID must increment I have already coded that the rid cookie adds 1 on every refresh. But I just wanted to ask, do I have to pre-bind on every refresh? or only on log in?
I have seen a few example scripts that binds every page reload. I cannot do a pre-bind on each page reload because I cannot remember the password, nor can I save the password somewhere in the cookie to remember (because that's a security issue).
So, how does pre-binding really work? I am using openfire as a xmpp server.
This is the code on my login
$xmppPrebind = new XmppPrebind('xxxx', $bosh_url, 'xxxx', false);
$xmppPrebind->connect($user->username, $password);
$xmppPrebind->auth();
$sessionInfo = $xmppPrebind->getSessionInfo(); // array containing sid, rid and jid
Session::put('bosh_url', $bosh_url);
Session::put('bosh_jid', $sessionInfo['jid']);
Session::put('bosh_sid', $sessionInfo['sid']);
Session::put('bosh_rid', $sessionInfo['rid']);
After authenticating the user successfully I also log him/her in to the openfire server.