1

Im using Sencha Touch 2 where i have a login form asking for username and password now i want to store user details via Session/Cookie so the user can logout,

i browsed some links which i got

Sencha-touch : save login / password (save session, multi-tasks)

but im being an new to sench touch develpment

any help using code examples will be of very great input for me

Thanks in advance

2 Answers 2

3

You can use the HTML5 localStore object. For instance, when a user logs in and your server request is made, on the callback of a successful server request you can store any necessary data. Here is a snippet from one of my apps:

loginCallback: function(options, success, response) { this.mainSplash.setMasked(false); var responseOjbect = Ext.JSON.decode(response.responseText); if (responseOjbect.success) { this.clearLoginStorage(); //runs a function to clear some login storage values if (rememberme) { localStorage.setItem("rememberme", 1); } else { localStorage.setItem("rememberme", 0); } localStorage.setItem("userid", responseOjbect.userid); localStorage.setItem("first_name", responseOjbect.first_name); localStorage.setItem("last_name", responseOjbect.last_name); localStorage.setItem("appsettingone", responseOjbect.appsettingone); localStorage.setItem("appsettingtwo", responseOjbect.appsettingtwo); localStorage.setItem("setdate", new Date()); if (!this.dashboard) { Ext.create('myApp.view.Dashboard', { //additional config }); } Ext.Viewport.setActiveItem(this.dashboard); } else { Ext.Msg.alert('Attention', responseOjbect.errorMessage, Ext.emptyFn); } } 

Once you have set your localStorage items, they can be retrieved or removed like so:

localStorage.getItem("user_id"); //retrieve localStorage.removeItem("userid"); //remove 

So when you call your logout function, just don't remove any localStorage objects you want to keep. Then you can call localStorage.getItem("VALUE") to retrieve them upon next login

Sign up to request clarification or add additional context in comments.

2 Comments

hi jeffery i made use of localStorage but no success -- my code localStorage.setItem("uid", "A"); localStorage.setItem("password", "B"); var ss =localStorage.getItem("uid"); console.log(retJson.password);
Same code works for me if i console.log your ss variable... maybe viewing the guide on HTML5 storage will help
0

This is something which is managed by the server, not the client, so you want to look at , not at sencha itself.

On a guess that you are using php, for something really basic, take a look at: http://www.html-form-guide.com/php-form/php-login-form.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.