Mega Code Archive

 
Categories / Php / Cookie Session
 

With this class you can use cookies with chips

<?php function getChips( $ChpName ) { global $$ChpName; $vals = split( "&", $$ChpName ); while( list ( $key, $val ) = each( $vals ) ) { list( $ChpName, $wert ) = split( "=", $val ); if ( $val ) { global $$ChpName; eval( "\$$ChpName = urldecode(\"$wert\");" ); } } } class CHIPS { var $Arr; function setChips( $CookieVar0 = "COOKIE-NULL", $CookieVar1 = "COOKIE-NULL", $CookieVar2 = "COOKIE-NULL", $CookieVar3 = "COOKIE-NULL", $CookieVar4 = "COOKIE-NULL", $CookieVar5 = "COOKIE-NULL", $CookieVar6 = "COOKIE-NULL", $CookieVar7 = "COOKIE-NULL", $CookieVar8 = "COOKIE-NULL", $CookieVar9 = "COOKIE-NULL" ) { $curr = "CookieVar0"; for ( $i = 0 ; $i < 10 && $$curr != "COOKIE-NULL"; $i++, $curr = "CookieVar".$i ) { $this->Arr[] = $$curr; } } function getParams() { // Declara las variables globales: if ( empty ( $this -> Arr ) ) $elements = 0; else $elements = count( $this -> Arr ); for( $i = 0; $i < $elements; $i++ ) { $CookieVar = $this -> Arr[$i]; global $$CookieVar; if ( $$CookieVar != "" ) { if ( $param != "" ) $param .= "&"; $param .= $CookieVar . "=" . urlencode( $$CookieVar ); } } return $param; } function createCookie( $name, $min ) { $value = $this -> getParams(); SetCookie( $name, $value, time()+ ( $min * 60 ), "/", "", 0 ); } }; ?>