1

I had created an ajax request in sencha touch 2, when i get a success message how can i set my return values to session and please also tell me a way through which i can get the value from session also.

 submitLoginForm: function() {
    var form = this.getLoginForm().getValues();

    Ext.Ajax.request({
        url: '../../authenticate.php',
        method: 'POST',

        params: {
            email: form.email,
            password: form.password
        },

        success: function(response) {
            var json = Ext.decode(response.responseText);
            if(json.message == 'success') {
                Ext.Msg.alert('Login Success.....');
                //Here i want to store return data in session
            } else {
                Ext.Msg.alert('Invalid Login Or Password.....');
            }
        },

        failure: function(response) {
            Ext.Msg.alert('The request failed.....');
        }
    });
},
Deepak
  • 104
  • 7

1 Answers1

1

on Success response, use HTML5 local storage to set and get the session variables:

var sessionObject = { 'var1': 1, 'var2': 2, 'var3': 3 };

// Put the session object into storage
localStorage.setItem('sessionObject ', JSON.stringify(sessionObject ));

// Retrieve the session  object from storage
var sessionObject = localStorage.getItem('sessionObject ');

console.log('sessionObject : ', JSON.parse(sessionObject ));
nuthan
  • 465
  • 2
  • 5
  • 19