View Full Version : If I want to destroy only part of a sessions' vars (php), what to do ?
leonidassavvides
08-11-2008, 11:10 PM
If I want to destroy only part of a sessions' vars (php), what to do ?
setting mean destroyed ?
$_SESSION['USERNAME']="";
djr33
08-11-2008, 11:22 PM
You can't really destroy values in the session data. You can change the session, which would then detach the old data, but it wouldn't even actually delete it from the server.
So, the best way to do this is to replace it. If you want to replace the whole array, that works. If you don't want to lose all of it, though, like you say, then just replace each value with what you want.
$_SESSION['somevar'] = ''; //set it to blank
techietim
08-12-2008, 11:56 AM
unset($_SESSION['USERNAME']);
Tim, that will destroy the session. He just wants the value gone, so if you were to do if(isset()), it'd be true.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.