Visualizzazione dei risultati da 1 a 9 su 9

Discussione: eliminare i coochie

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,804

    eliminare i coochie

    ciao ragazzi esisto un modo con il javascript di eliminare i coochie conosciete qualche script? grazie ciao
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  2. #2
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,804
    ciao e grazie ma scusa una cosa come funziona io devo dargli l estenzione del javascript e dal html do il collegamento giusto
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  4. #4
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    puoi cancellare un cookie settandone la scadenza ad una data passata.

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,804
    ma io sto script lo devoinserire nel html non ci sto capendo molto come usarlomi spieghi perfavore
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  6. #6
    Originariamente inviato da rocco.mod
    ma io sto script lo devoinserire nel html non ci sto capendo molto come usarlomi spieghi perfavore
    Devi mettere quel codice in un file js nella head
    del tuo file html lo inserisci:

    Codice PHP:
    <script type="text/javascript" src="Cookie.js"></script> 
    e cancelli il cookie in questo modo

    Codice PHP:
    Cookie.unset('nomeCookie'); 
    Se vuoi capire come funziano i cookie fatti un giretto
    qui

    alla fine dell'articolo ci sono tre funzioni per set/get/delete
    dei cookies .........


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  7. #7
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    Questo è interessante perchè molto semplice (trovato qui tempo fa )
    codice:
         	   	  
    /** http://www.devpro.it/code/106.html **
     * Object Cookie
     * 	fast and simple way to manage one or more cookie from javascript.
     *
     * NOTE:
     * This object escape values then saved var will be always a string.
     * To storage complex variables or to preserve saved variable informations
     * you should combine this object with PHP_Serializer.
     * [ http://www.devpro.it/javascript_id_102.html ]
     * _____________________________________________
     *
     * QUICK EXAMPLE:
     *	Cookie.set('var', 'value');
     *	alert(Cookie.get('var'));
     *	Cookie.unset('var');
     *
     * EXAMPLE WITH PHP_Serializer OBJECT:
     *	var php = new PHP_Serializer();
     *	var complexVar = [true, 'test', 12345];
     *	Cookie.set('complexVar', php.serialize(complexVar));
     *	alert( typeof php.unserialize( Cookie.get('complexVar') ) );
     *	// will be object and not string then returned value is an array
     *	Cookie.unset('complexVar');
     * ---------------------------------------------
     * @author              Andrea Giammarchi
     * @site		www.devpro.it
     * @date                2005/12/19 11:00
     * @lastmod             2005/12/19 11:00
     * @credits		Special thanks to Dustin Diaz
     *			[ http://www.dustindiaz.com/top-ten-javascript/ ]
     * @version             1.0 tested FireFox 1.5, IE 6 SP2 and Opera 8
     */
    var Cookie = {
    
    	/**
    	 * public method, returns value for chosed name or false if is not present
    	 *	Cookie.get( cookiename:String ):String
    	 * @param	String		name of saved cookie
    	 * @return	String		value saved with chosed name
    	 */
    	get: function(name) {
    		var dc = document.cookie;
    		var cl = dc.indexOf(name+'=')+name.length;
    		if(++cl > name.length) {
    			var ce = dc.indexOf(';',cl);
    			if(ce == -1)
    				ce = dc.length;
    			cl = unescape(dc.substr(cl,(ce-cl)));
    		}
    		else
    			cl = false;
    		return cl;
    	},
    	
    	/**
    	 * public method, sets a cookie
    	 *	Cookie.set( name:String, value:Mixed[, exp:Int[, path:String[, domain:String[, secure:Boolean ]]]]):Void
    	 * @param	String		name of cookie
    	 * @param	Mixed		cookie value
    	 * @param	Int		expiration date ( 0, 1, ... N days )
    	 * @param	String		valid path for this cookie
    	 * @param	String		domain for this cookie
    	 * @param	Boolean		secure ( for example in https sites )
    	 */
    	set: function(name, value, exp, path, domain, secure) {
    		var c = new Array();
    		c.push(name + '=' + escape(value));
    		var e = (exp > 0);
    		if(e) {
    			var n = new Date();
    			exp = new Date(n.getTime()+(exp*86400000));
    			c.push('expires='+exp.toGMTString());
    		}
    		if(path){c.push('path='+path);}
    		if(domain){c.push('domain='+domain);}
    		if(secure){c.push('secure');}
    		document.cookie = c.join(';');
    	},
    	
    	/**
    	 * public method, removes a cookie if present.
    	 *	Cookie.unset( name:String[, path:String[, domain:String]] ):Boolean
    	 * @param	String		saved cookie name
    	 * @param	String		path used for this cookie
    	 * @param	String		domain used for this cookie
    	 * @return	Boolean		true if was present and is removed or false
    	 */
    	unset: function(name, path, domain) {
    		var result = this.get(name);
    		if(result != false) {
    			var c = new Array();
    			c.push(name + '=');
    			if(path){c.push('path=' + path);}
    			if(domain){c.push('domain=' + domain);}
    			c.push('expires=Thu, 01-Jan-1970 00:00:01 GMT');
    			document.cookie = c.join(';');
    		}
    		return !!result;
    	}
    }
    :quote: c'è pure l'esempio

    * QUICK EXAMPLE:
    * Cookie.set('var', 'value');
    * alert(Cookie.get('var'));
    * Cookie.unset('var');
    Pietro

  8. #8
    @pietro09

    che fai copi ? :master:


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  9. #9
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    Originariamente inviato da whisher
    @pietro09

    che fai copi ? :master:


    Adesso che me lo hai fatto notare, non posso fare altro che confermare: sono un copione
    Pietro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.