note 86173 modified in function.session-set-save-handler by felipe

From: Date: Tue, 07 Oct 2008 19:56:49 +0000
Subject: note 86173 modified in function.session-set-save-handler by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145139@lists.php.net to get a copy of this message
if you simply append the information from session variables every time you'll have many multiples for variables each time they are changed. a simple way to do this is explode the data twice to seperate the variable name from the other relevant information and foreach() check against the stored set. here is a little bit of a mess i wrote to do it. assuming stored session variables in both database and passed through function: <?php $buffer = array(); $buffer = explode('|',$sessiondata); $buf1 = array(); $buf2 = array(); $finalbuff = ''; foreach($buffer as $i){ $i = explode(';',$i); foreach($i as $b){ array_push($buf1,$b); } } $buffer = explode('|',$result['data']); foreach($buffer as $i){ $i = explode(';',$i); foreach($i as $b){ array_push($buf2,$b);}} $z = 0; $x = 0; while($buf2[$z]){ while($buf1[$x]){ if($buf2[$z] == $buf1[$x]){ $buf2[($z+1)] = $buf1[($x+1)]; } $x+=2; } $z+=2; } foreach($buf2 as $i){ $finalbuff .= $i; } ?> $sessiondata is the variable passed through the function and $result['data'] is the data stored in an sql database. --was-- if you simply append the information from session variables every time you'll have many multiples for variables each time they are changed. a simple way to do this is explode the data twice to seperate the variable name from the other relevant information and foreach() check against the stored set. here is a little bit of a mess i wrote to do it. assuming stored session variables in both database and passed through function: $buffer = array(); $buffer = explode('|',$sessiondata); $buf1 = array(); $buf2 = array(); $finalbuff = ''; foreach($buffer as $i){ $i = explode(';',$i); foreach($i as $b){ array_push($buf1,$b); } } $buffer = explode('|',$result['data']); foreach($buffer as $i){ $i = explode(';',$i); foreach($i as $b){ array_push($buf2,$b);}} $z = 0; $x = 0; while($buf2[$z]){ while($buf1[$x]){ if($buf2[$z] == $buf1[$x]){ $buf2[($z+1)] = $buf1[($x+1)]; } $x+=2; } $z+=2; } foreach($buf2 as $i){ $finalbuff .= $i; } $sessiondata is the variable passed through the function and $result['data'] is the data stored in an sql database. http://php.net/manual/en/function.session-set-save-handler.php

« previous php.notes (#145139) next »