I'm working on browser javascript xmpp client that connects anonymously to my server.  

But when a user reloads the page or leaves it and subsequently returns to it I need
to reconnect to the server with the same anonymous account. How can I do this?

I'm using Strophe library (xmpp over bosh). So I already tried to do the following:

```
connection.connect(jid, "", onConnect);

```

this results in failure response from server:

```
<body xmlns='http://jabber.org/protocol/httpbind'>
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<not-authorized/></failure>
</body>

```

and also:

```
connection.attach(jid, sid, rid, onConnect);

```

where jid, rid and sid are from cookies in both cases.
The second method is ok, but I can't manage with rid parameter correctly in all popular browsers.