Search code examples
phpsessionsession-variablesphp4

Put a variable SESSION in an other variable, delete SESSION content variable


I've an application in PHP 4.3.9 and I've a problem with SESSION. When I put a variable SESSION in an other variable, like this :

$tempInsInscription = $_SESSION['ins_inscription'];

$_SESSION['ins_inscription'] content is removed.

I don't understand why. Is a PHP4 particularity ?


EDIT

I tried many case to found where exactly I lose my content and this is in a foreach :

reset($tempInsInscription);
foreach($tempInsInscription as $key => $ins_inscription){
    if(is_array($ins_inscription)){
        reset($ins_inscription);
        foreach($ins_inscription as $key_etape => $etape){
            $_SESSION["dossier"][$key_etape]=$etape;
        }       
    }else{
        $_SESSION["dossier"][$key]=$ins_inscription;
    }
}

SOLUTION

I found a solution to solve my problem. here my new code & it's works perfectly :

$tempInsInscription = $_SESSION['ins_inscription'];
$_SESSION['ins_inscription'] = $tempInsInscription;

reset($tempInsInscription);
while(list($key, $ins_inscription) = each($tempInsInscription)) {
    if(is_array($ins_inscription)){
        reset($ins_inscription);
        while(list($key_etape, $value_etape) = each($ins_inscription)) {
            $dossier[$key_etape]=$value_etape;
        }
    }else{
        $dossier[$key]=$ins_inscription;
    }
}

Solution

  • SOLUTION

    I found a solution to solve my problem. here my new code & it's works perfectly :

    $tempInsInscription = $_SESSION['ins_inscription'];
    $_SESSION['ins_inscription'] = $tempInsInscription;
    
    reset($tempInsInscription);
    while(list($key, $ins_inscription) = each($tempInsInscription)) {
        if(is_array($ins_inscription)){
            reset($ins_inscription);
            while(list($key_etape, $value_etape) = each($ins_inscription)) {
                $dossier[$key_etape]=$value_etape;
            }
        }else{
            $dossier[$key]=$ins_inscription;
        }
    }