PDA

View Full Version : Setting cookie



ShikarnO
25 Aug 2010, 6:12 AM
How i can set cookie in this code

onSuccess:function(form, action) {
Ext.util.Cookies.set("userId", 1);
Login.win.hide();} // onSuccess FINISH
using this json-response

{"success":true,"user":{"email":1,"firstName":"vasya","id":1,"lastName":"pupkin","login":"vasya","password":"qwe"}}

I want to set userId to user.id from response

prophet
25 Aug 2010, 7:31 AM
Depending on the rest of your code, you may or may not need to decode the JSON response from the server. Ext.decode() will do that for you.

You could probably just use:

Ext.util.Cookies.set("userId", action.result.user.id)