Forum Moderators: coopster

Message Too Old, No Replies

Grouping Session Variables

         

HoboTraveler

7:20 am on Apr 28, 2009 (gmt 0)

10+ Year Member



Hi All,

I need to unset about 20 session variables before a form is loaded.

Trouble is, everytime I add a new variable, I have to add the variable to the list of variables that need to be unset.

Is possible to set all these variables as part of a group or something? If the main group variable was reset, all variables belonging to that group would be auto unset.

Any ideas?

I do not want to destroy the session.

Thanks

cameraman

11:28 am on Apr 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can store arrays in sessions.
$_SESSION['group1']['fred'] = "hello";
$_SESSION['group1']['joe'] = "hi";
$_SESSION['group2']['susan'] = "howdy";

unset($_SESSION['group1']);

HoboTraveler

11:31 am on Apr 28, 2009 (gmt 0)

10+ Year Member



Brilliant!

Thank You