Okay, I'm having a little trouble here. I've set up a site so that you can change a two settings, using three Session variables/cookies to do so. Basically, one, 'set', determines whether or not the user has visited before. If $SESSION['set'] is set, it means they're in the middle of a visit and it takes the $SESSION values for the other two settings ('theme' and 'numss'). If $SESSION['set'] isn't set, it checks for $COOKIE['set']. If not, it writes all the default variables (both cookies and session variables). Basically, the problem is that, even though $SESSION['set'] is set to the right value, my script is ignoring it and reading from $COOKIE['set'] instead. Here's the code:
$themes = array (
'1' => '/home/ketsuka/public_html/frozensky/Themes/v1/',
);
/* Get Theme Info */
if ($_SESSION['set'] == 'yes') {
$themepath = $themes[$_SESSION['theme']];
$numss = $_SESSION['numss'];
setcookie ('set', 'yes', time () + 3600 * 24 * 90);
setcookie ('theme', $_SESSION['theme'], time () + 3600 * 24 * 90);
setcookie ('numss', $_SESSION['numss'], time () + 3600 * 24 * 90);
} elseif ($_COOKIE['set'] == 'yes') {
$_SESSION['set'] = 'yes';
$_SESSION['theme'] = $_COOKIE['theme'];
if (isset ($themes[$_SESSION['theme']])) {
$themepath = $themes[$_SESSION['theme']];
} else {
$_SESSION['theme'] = '1';
$themepath = $themes[$_SESSION['theme']];
};
$_SESSION['numss'] = $_COOKIE['numss'];
if ($_SESSION['numss'] <= 0) {
$_SESSION['numss'] = '25';
}
$numss = $_SESSION['numss'];
setcookie ('set', 'yes', time () + 3600 * 24 * 90);
setcookie ('theme', $_SESSION['theme'], time () + 3600 * 24 * 90);
setcookie ('numss', $_SESSION['numss'], time () + 3600 * 24 * 90);
} else {
session_start ();
setcookie ('set', 'yes', time () + 3600 * 24 * 90);
setcookie ('theme', '1', time () + 3600 * 24 * 90);
setcookie ('numss', '25', time () + 3600 * 24 * 90);
$_SESSION['set'] = 'yes';
$_SESSION['theme'] = '1';
$themepath = $themes[$_SESSION['theme']];
$numss = $_SESSION['numss'];
};
For troubleshooting, I've tried to print () out all six variables and they all show up the right way. I've never had trouble with any other $_SESSION variables (I tested some just now to make sure they don't get erased instantly like this one apparently does). Any ideas?