So while I've been working on a much more refined way of figuring out all the visitor's preferences I'm curious: is it more efficient to execute PHP to parse the settings every single time or execute only when something changes and store the information in variables assigned to the visitor's session instead?
While far from complete here is what I'm messing with (just to help give a vague idea what PHP would be doing every single time if I don't end up storing the data in session variables)...
Code: Select all
<?php
$settings_default = array(
'audio'=>'0',
'broadbandimages'=>'0',
'checkbox'=>'0',
'columns'=>'1',
'connection'=>'0',
'css3'=>'0',
'csspatch'=>'1',
'cursors'=>'0',
'dhtmleffects'=>'0',
'dtd'=>'1',
'initialfocus'=>'search_query',
'keyboardlayout'=>'developer',
'mediatype'=>'ns',
'pagination'=>'form',
'personality'=>'0',
'powerkeys'=>'0',
'sidebar'=>'20',
'sounds'=>'0',
'theme'=>'classic'
);
foreach ($settings_default as $var=>$val)
{
if (isset($_GET[$var])) {$$var = $_GET[$var];}
else if (isset($_POST[$var])) {$$var = $_POST[$var];}
else if (isset($_COOKIE['settings']))
{
$settings_cookie_pair = explode('_',$_COOKIE['settings']);
foreach ($settings_cookie_pair as $var_c=>$val_c)
{
$var_c = explode('.',$val_c);
$var1 = $var_c['0'];
$$var1 = $var_c['1'];
}
}
else
{
$$var = $val;
}
}
?>