cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1622
Views
0
Helpful
7
Replies

How to keep Jabber SDK keep login after refresh browser page

hanwang85
Level 1
Level 1

Hi all,

I am using the Jabber SDK sample demo. I am be able to login and connect to device.

However, when I do a refresh, it seems it lost the connection and I have to enter my username, password and then pick device to connect again.

Is there any way to keep my session logged in?

Or if I refresh, I must re-do the login process?

7 Replies 7

npetrele
Cisco Employee
Cisco Employee

Yes, you'd have to login again after a refresh, since the browser resets the entity set. 

Just curious, why do you need to refresh a Jabber session window? 

Hi npetrele,

Thanks for your reply.

Say we we have an Agent Web integrated Jabber SDK, So, every time when agent log into the web. We will ask them to input their jabber credentials to connect to their jabber devices. Then they can answer jabber calls from our agent web.

But I think the user may accidentally refresh the page when they are not on a call or even close that tab and reopen it again. So, for this situation, when they back, they are still logged in our web, but they have to input their jabber credentials to login jabber again to make device ready to receive calls again?


Thanks a million.

Have you ever seen a page that warns you with a popup if you try to leave the page?  I haven't looked into every possible way they do that, but I imagine they capture the event in Javascript and then act on it (see below).  You might consider implementing something like that as a way to prevent users from leaving the page (closing the tab) or even refreshing the page.  Just include in the message that they'll have to log in again if they proceed. 

I found this code on stack overflow for use with jQuery:

$(window).bind('beforeunload', function(e) {
  
// Your code and validation
  
if (confirm) {
  
return "Are you sure?";
  
}
});


Here is an example without jQuery:


window.onbeforeunload = function (evt) {

    var message = ‘Are you sure you want to leave?’;

    if (typeof evt == ‘undefined’) {

        evt = window.event;

    }

    if (evt) {

        evt.returnValue = message;

    }

    return message;

}


Another thought occurred to me.  In addition to the strategy outlined above ("are you sure you want to leave?"), you could store the login information in a cookie.  Then automatically re-login after a refresh.  This isn't very secure, so you'd have to weigh the cost/benefit of doing this.  Just a thought. 

I think Jabber allow you to use ciphered password to login, right?

When I login first time, I can get:

   "password": {

   "cipher": "cucm",

   "encrypted": "123123123"

   }

from registration object.


So, I was thinking to save this in localstorage, and if user refresh the browser, I will use this to automatically login again.



I have tried to do the same thing. However, I can't register phone with the encrypted password. Do you success?

I answered too soon, and later discovered that it's actually easy to maintain a login after page refresh.  I have an almost complete demo that uses the ability to maintain logins on page refresh:

Jabber SDK Chat Demo with Material Design

Also, there are a number of examples for how to get things to persist in the CAXL/doc/examples directory after you get the Jabber SDK. Just look for filenames with the word "persist" in them. 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: