Question regarding naming $_SESSION variables
There is something that I can do in ColdFusion that I am wondering if the same thing can be done in PHP5.
In CF, you can name a session variable using dot-syntax that will allow you to "group" session variables under one parent session variable.
Now, if I wanted to delete JUST the groupB variables, but keep the groupA variables, instead of going through and deleting each and every one of them, I can simply:
<cfset session.groupA.firstName = "Jack">
<cfset session.groupA.lastName = "Smith">
<cfset session.groupB.firstName = "John">
<cfset session.groupB.lastName = "Doe">
.. and that will remove all session variables under the groupB key.
Does PHP have a naming convention for $_SESSION variables that is similar? Something like, maybe, $_SESSION['groupA']['firstName']?
Arrays are referenced the way you already know, and deleted using unset:
I guess it's similar?
$_SESSION['groupA'] = array(
'firstName' => 'Jack',
'lastName' => 'Smith'
$_SESSION['groupB'] = array(
'firstName' => 'John',
'lastName' => 'Doe'
unset($_SESSION['groupB']); //Removes groupB
Looks like it is similar, to me, bionoid. I'll give it a shot and let you know.
Spot on, bionoid! Thanks!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)