function isJson(str) {
    try {
        JSON.parse(str);
    } catch (e) {
        return false;
    }
    return true;
}

var admin_id;
var username;
var modules;
var random_string;
var is_super_admin;

Ext.Ajax.request({
    url: base_url+admin_folder+'login/info'
    ,method: 'GET'
    ,async: false
    ,success: function(result,request){
        var jsonData = Ext.util.JSON.decode(result.responseText);

        admin_id       = jsonData.admin_id;
        username       = jsonData.username;
        modules        = jsonData.modules;
        random_string  = jsonData.random_string;
        is_super_admin = parseInt(jsonData.is_super_admin);
    }
    ,failure: function(){}
    ,headers: {
        'Powered-By': 'Ext'
    }
});

Ext.Ajax.on('beforerequest', function (conn, options) {
	if (typeof(options.params) == "undefined") {
       options.params = {'csrf_token': csrf_hash};
    } else {
       options.params.csrf_token = csrf_hash;
    }                        
}, this);
Ext.Ajax.on('requestcomplete', function (conn, response, options) {
	if(isJson(response.responseText)){
		var jsonData = Ext.util.JSON.decode(response.responseText);
		if(jsonData.csrf_token){
			csrf_hash = jsonData.csrf_token;
		}
	}                
}, this);