Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A better way ? 1

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hi :)

I've always tried to impose hierarchy and consistency in the use of session variables in order
to keep track of them very easily, but the problem is that I end up with very long session names such like :

$_SESSION["my_site"]["mod"]["shop"]["pics"]["folders"]
$_SESSION["my_site"]["mod"]["blog"]["pics"]["folders"]

But I like the fact that I can list all the variables used with print(nl2br(print_r($_SESSION["my_site"], true)));

Anyway, if you know a better way, please let me know! ;)
 
variable naming conventions are pretty much a matter of personal taste. unless you are developing en groupe in which case they are a survival tactic. read the style manual in the pear repository for a good summary on coding style and variable naming.

i would not name session variables the way that you are. for example i would not use a site delimiter, but rather have sessions named differently for different sites
Code:
session_name['mysite_1'];
session_start();

for the rest - i can't tell but if you are finding it takes a long time to retrieve the data because you're typing out long session vars then that's probably telling you something! Personally, i do sometimes keep data in arrays in sessions but very seldom do i go as deep as you post above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top