This is my situation. I have 3 sets of data used on every page of my website. Two of these never change, and the reason they are stored in MySQL and recalled into the $_SESSION variable is simply because I want to have one place to update/change them if I ever need to.
What I have been wondering is if I should leave the user specific variables in the session, and define the other variables in another file/array which is called on every page. This makes it easier to manage, less code, and no MySQL, but possibly more arrays.
So right now I have something like (which is only run once):
Expand|Select|Wrap|Line Numbers
- /*MySQL get table 1 variables*/
- /*Store each fetched variable into $_SESSION*/
- /*MySQL get table 2 variables*/
- /*Store each fetched variable into $_SESSION*/
- /*MySQL get table 3 variables*/
- /*Store each fetched variable into $_SESSION*/
- /*Do stuff with $_SESSION['table1var1'], $_SESSION['table2var3'], $_SESSION['table1var2'], $_SESSION['table3var16']*/
Expand|Select|Wrap|Line Numbers
- /*Do once: MySQL get table 1 variables*/
- /*Do once: Store each fetched variable into $_SESSION*/
- /*Do every page: include table2.php*/
- /*Do every page: include table3.php*/
- ...
Expand|Select|Wrap|Line Numbers
- $table2['var1'] = 10;
- $table2['var2'] = "John";
- $table2['var3'] = 19/10/1986;
- ***OR***
- $table2_var1 = 10;
- $table2_var2 = "John";
- $table2_var3 = 19/10/1986;