View Poll Results: Do you think I clearly explain the problem and give enough elements to solve it ?

Voters
0. You may not vote on this poll
  • Yes, it's clear.

    0 0%
  • Can largely be better......

    0 0%
  1. #1
    Sencha Premium Member sencha-dev2's Avatar
    Join Date
    Jun 2012
    Location
    France
    Posts
    59
    Answers
    2
    Vote Rating
    0
    sencha-dev2 is on a distinguished road

      0  

    Default Answered: Cookies !!

    Answered: Cookies !!


    No, I'm not talking about those delicious cakes, but about those little data packages we can use to store data on the user's computer.

    I have a problem, cause I cannot use it correctly. Here's what I did to watch what's been saved up :

    Code:
        var n = Ext.util.Cookies.get('cookLog');
        console.log(n);
    It only retrieves [Object Object] in my console. So I post here the code I used to "set" the cookie.

    Code:
        var log = Ext.getCmp('loginPageConnexion').getValue(); // textfield
        var mdp = Ext.getCmp('mdpPageConnexion').getValue(); // textfield masked for passwords
        var svn = Ext.getCmp('souvenirLogConnexion').getValue(); // checkbox
        console.log(svn);
        var dt = new Date(), dtj = dt.getDate(), dtm = dt.getMonth(), dta = dt.getFullYear();
        if(dtm == 0 || dtm == 2 || dtm == 4 || dtm == 6 || dtm == 7 || dtm == 9 || dtm == 11) {
            if(dtj > 24) {
                dtj = dtj - 24;
                if(dtm == 11) {
                    dta = dta + 1;
                    dtm = 0;
                } else {
                    dtm = dtm + 1;
                }
            }
        } else {
            if(dtm == 3 || dtm == 5 || dtm == 8 || dtm == 10) {
                if(dtj > 23) dtj = dtj - 23;
                dtm = dtm + 1;
            } else {
                if(dtj > 21) dtj = dtj - 21;
                dtm = dtm + 1;
            }
        }
        dt = new Date(dta, dtm, dtj);
        if(svn) {
            Ext.MessageBox.confirm('Avertissement', 'Ne conservez ces informations de connexion que si vous ĂȘtes le seul utilisateur de ce poste. Confirmer ?', function(btn) {
                if(btn == 'no') {
                    svn = false;
                    ctrlr.procedureConnexion(log, mdp, svn, dt);
                } else {
                    svn = true;
                    ctrlr.procedureConnexion(log, mdp, svn, dt);
                }
            });
        } else {
            svn = false;
            ctrlr.procedureConnexion(log, mdp, svn, dt);
        }
    
    
        if(svn) 
        valeursCookie = new Object();
        valeursCookie.log = log;
        valeursCookie.mdp = mdp;
        valeursCookie.loginUtil = res.loginUtilisateur;
        valeursCookie.id = res.id;
        Ext.util.Cookies.set('cookLog', valeursCookie, dt);
    }
    I must precise that I set the 'requires: ['Ext.util.Cookies']' higher in the file.

  2. You need to serialize the object, cookies use strings. Use Ext.encode to make the object be JSON and Ext.decode to turn the JSON to an object.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,118
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You need to serialize the object, cookies use strings. Use Ext.encode to make the object be JSON and Ext.decode to turn the JSON to an object.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha Premium Member sencha-dev2's Avatar
    Join Date
    Jun 2012
    Location
    France
    Posts
    59
    Answers
    2
    Vote Rating
    0
    sencha-dev2 is on a distinguished road

      0  

    Default


    Thanks a lot !

Thread Participants: 1

Tags for this Thread