Bug #18071: unset($_SESSION['name']); not works when varible is readed before unset

From: Date: Sun, 30 Jun 2002 11:35:22 +0000
Subject: Bug #18071: unset($_SESSION['name']); not works when varible is readed before unset
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12584@lists.php.net to get a copy of this message
From: lampa@brutusmud.net Operating system: win 2k, debian 2.2 PHP version: 4.2.1 PHP Bug Type: Session related Bug description: unset($_SESSION['name']); not works when varible is readed before unset when using unset($_SESSION[...]) insted session_unregister(...) and before calling read _$SESSION[...] variable WILL NOT unset. please try these examples and see result. here is method how to produce this bug (you must have cookies enabled): 1. run script 2. reload page (you should see 2 $_SESSION arrays with the same value) 3. click on unset link 4. now you should see first array filled with test value and second should be empty - that's OK - but variable test should be deleted from session 5. reload page 6. here is BUG: i unset session variable test so i shouldn't exists, but exists. --- 7. comment line marked #fatal and go to repeat process from begining on step 6. both arrays will be empty!!!! <?php session_start(); echo '<pre>'; print_r($_SESSION); if (isset($_GET['submit'])) { $test = $_SESSION['test']; # fatal unset($_SESSION['test']); } else { $_SESSION['test'] = 'this is test'; } echo '<a href="'.$_SERVER['PHP_SELF'].'?submit=yes">unset</a><br>'; print_r($_SESSION); echo '</pre>'; ?> replace unset($_SESSION['test']); with session_unregister('test'); and repeat process - here will be everything OK. -- Edit bug report at http://bugs.php.net/?id=18071&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18071&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18071&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18071&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18071&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18071&r=support Expected behavior: http://bugs.php.net/fix.php?id=18071&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18071&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18071&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18071&r=globals

« previous php.bugs (#12584) next »