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%
Results 1 to 3 of 3

Thread: Cookies !!

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

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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

    Default

    Thanks a lot !

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •