Jump to content

Looping through an unset statement


slanton

Recommended Posts

Hmm.. Let me try..

[b]Edit[/b]:
OMG >.< Now then I know it's not working in loop, or you wanna use a long way ?
[code]$_SESSION['test1'] = "";
$_SESSION['test2'] = "";[/code]

Hmm not sure this thread will helps anot, [a href=\"http://www.codecomments.com/message242702.html\" target=\"_blank\"]http://www.codecomments.com/message242702.html[/a]
Your code will not work as PHP is unsetting a session var called 'test$i' it is treating your variable as-is meaning it is not swaping $i with its value.

So change your unset code to this:
[code]unset($_SESSION['test' . $i]);[/code]
Now PHP will parse the variable $i rather than treating it as text.

Also if you want to destroy a session you should use session_destroy();
[!--quoteo(post=387119:date=Jun 23 2006, 06:26 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 23 2006, 06:26 AM) [snapback]387119[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Also if you want to destroy a session you should use session_destroy();
[/quote]
Thanks..that works.
Doesn't session_destroy kill all session data ..I just want to unset a particular variable.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.