Hi guys,
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):
Instead I was thinking:
The included files could be in the form:
I would like to do the 1st option but I wonder if more arrays will be noticeably slower, and if doing this on every page will also slow down the page load? Should I just leave it all in the $_SESSION array? Any advice would be greatly appreciated.
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):
Code:
/*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']*/
Code:
/*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*/ ...
Code:
$table2['var1'] = 10; $table2['var2'] = "John"; $table2['var3'] = 19/10/1986; ***OR*** $table2_var1 = 10; $table2_var2 = "John"; $table2_var3 = 19/10/1986;
Comment