jeudi 17 mars 2016

Flooring a random exponential value for a cookie key

Is it possible to get string with length of 17 by using such code? We're saving cookie in a client's browser and then get it from this browser.

function getPartnerVisitorId() {
    var pvid = cookies.get('pvid') || Math.floor(Math.random() * Math.pow(10, 15)).toString();
    cookies.setOnRoot('pvid', pvid, 365 * 24 * 60 * 60);
    return pvid;
};

We think that "pvid" should be maximum of 16 digits length, but sometimes (about 5% of cookies) we get 17 digits length of this cookie.

Also we've noticed that all of strange cookies are even numbers and most of them (75%) had zero as the last digit




Aucun commentaire:

Enregistrer un commentaire