Search code examples
extjsextjs4extjs-mvc

ExtJS Default Headers (token authorization) Page Refresh


I have my ExtJS application that on success login I set an Authorization Token so I can send that on every Ajax Call to my server:

success: function (response, opts)
                {
                    var obj = Ext.decode(response.responseText);

                    // set authToken
                    util.Util.authToken = obj.data.SessionId;

                    Ext.Ajax.defaultHeaders = {
                        'Authorization': 'Token' + obj.data.SessionId
                    };

It's working great. Now I implement Ext.ux.Router so I can refresh my browser and I can stay where I was, but I realize that when my browser refresh I loose my defaultHeader token.

Any clue on how to solve this?


Solution

  • What about save this SessionId in cookie? And if it exists - use it, otherwise send request.