In that case, you need to combine multiple formfields into one cookie. A
cookie can handle a large amount of data, 4 KB is enough for pretty
large text fields. It is the maximum of 20 that is a pain in the ass.

Try this to set your cookies. 

USAGE for Storage:
var tmp = new superCookie('cookiename');
tmp.add('subcookiename','value');


And for retrieval:
var tmp = new superCookie('cookiename');
tmp.load();

var value = tmp.get('subcookiename');




var cookie = document.cookie;
function getcookie(name) { // use: getCookie("name");
    var index = cookie.indexOf(name + "=");
    if(index == -1){
                return '';
        }
    index = cookie.indexOf("=", index) + 1;
    var endstr = cookie.indexOf(";", index);
    if (endstr == -1){
                endstr = cookie.length; 
        }
    return unescape(cookie.substring(index, endstr));
  }

function setcookie(name,value) {
        if(document.cookie != document.cookie){
        index = document.cookie.indexOf(name);
        }else{ 
        index = -1;
        }
        if(index == -1){
        document.cookie = name + '=' + escape(value) + ';
expires=Monday, 04-Apr-2010 05:00:00 GMT';
        }
}

function superCookie(name){
        this.name = name;
        this.raw = [];
        this.serialized; 
        this.deserialized = []; 
}

superCookie.prototype = {
        
        serialize:function(){
                
                var i = this.raw.length;
                var tmp = [];
                
                while(i--){
        
tmp.push('{name:\''+this.raw[i].label+'\',value:\''+this.raw[i].data+'\'
}');
                }
                this.serialized = tmp.join();
                return this.serialized;
                
        },
        deserialize:function(){
                
                if(!this.serialized){
                        return;
                }               
                
                var self = this;
                this.serialized.replace(/\{[^}]+\}/g,
function(match){self.deserialized.push(match)})
                return this.deserialized;
                
        },
        add:function(name,value){
                if(value.length <= 0){
                        value = 'null';
                }
                this.raw.push({label:name,data:escape(value)})
        },
        get:function(name){
                var set = this.deserialize();
                if(typeof set == 'undefined'){
                        return '';
                }
                var i = set.length;
                while(i--){
                        eval('var tmp = ' + set[i] + ';');
                        if(tmp.name == name){
                                var value = unescape(tmp.value);
                                if(value != null && value != 'null'){
                                        return value;
                                }else{
                                        return '';
                                }
                                break;
                        }
                }
                return '';
        },
        toRaw:function(){
                var set = this.deserialize();
                if(typeof set == 'undefined'){
                        return;
                }
                var i = set.length;
                this.raw = [];
                while(i--){
                        eval('var tmp = ' + set[i] + ';');
        
this.raw.push({label:tmp.name,data:escape(tmp.value)})
                }
        },
        load:function(){
                this.serialized = getcookie(this.name);
                this.toRaw();
        },
        save:function(){
                setcookie(this.name,this.serialize());
        }
}





Micha Schopman
Project Manager

Modern Media, Databankweg 12 M, 3821 AL  Amersfoort
Tel 033-4535377, Fax 033-4535388
KvK Amersfoort 39081679, Rabo 39.48.05.380

------------------------------------------------------------------------
------------------------------------------------------------------------
-----
Modern Media, Making You Interact Smarter. Onze oplossingen verbeteren
de interactie met uw doelgroep. 
Wilt u meer omzet, lagere kosten of een beter service niveau? Voor meer
informatie zie www.modernmedia.nl 
------------------------------------------------------------------------
------------------------------------------------------------------------
-----
-----Original Message-----
From: Aaron DC [mailto:[EMAIL PROTECTED] 
Sent: maandag 27 juni 2005 10:39
To: CF-Talk
Subject: Re: This is crazy this is crazy this is crazy!

This would be an interesting point to pursue - when submitting the form
you
set a cookie for EVERY form field - may be better off saving it in a
session
variable??

Live headers / Page info via Netscape / Mozilla etc are very useful when
looking at things like this.

Aaron


----- Original Message -----
From: "Micha Schopman" <[EMAIL PROTECTED]>
To: "CF-Talk" <cf-talk@houseoffusion.com>
Sent: Monday, June 27, 2005 5:57 PM
Subject: RE: This is crazy this is crazy this is crazy!


> Will,
>
> You might check the amount of cookies you are setting. Per domain you
> are allowed to set a maximum of 20 cookies in browsers, whereas each
has
> a maximum of 4 KB. If you go over these 20 cookies, the FIFO system
> (First in First Out) is doing the job to remove the oldest cookies
> automatically. So it might well be, that your session cookie gets
> removed from the browser because it has reached its maximum amount of
> cookies.
>
> If you really need to set a bigger amount of cookies you must create a
> wrapper for it. I have created one if you really need it.
>
> Micha Schopman
> Project Manager




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210582
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to