Problem with $_SESSION variables
Posted: Wed Jan 26, 2011 9:35 am
Hi Guys,
I am trying to set my page to pass the configuration element as a SESSION variable, to save it having to reload from the database each time the page refresehes. But for some reason I can't get it to work.
I start off by checking for a particular SESSION Variable to check whether or not to load form SESSION variables, or to load form the database.
After this it carries out the necessary actions. Then at the end of the page I load everything back into SESSION variables to be carried over. But it isn't working.
Whenever I set $_SESSION['ConfRun'] = 0 it tells me that none of the variables have been set, and I get an error
I am trying to set my page to pass the configuration element as a SESSION variable, to save it having to reload from the database each time the page refresehes. But for some reason I can't get it to work.
I start off by checking for a particular SESSION Variable to check whether or not to load form SESSION variables, or to load form the database.
After this it carries out the necessary actions. Then at the end of the page I load everything back into SESSION variables to be carried over. But it isn't working.
Code: Select all
// TOP OF THE PAGE
if(isset($_SESSION['ConfRun'])){
$ConfRun = $_SESSION['ConfRun'];
}else{
$ConfRun = 1;
};
IF ($ConfRun == 0) {
$config[] = array('sendEmail' => $_SESSION['sendEmail'],
'emailAddress' => $_SESSION['emailAddress'],
'pageRefresh' => $_SESSION['pageRefresh'],
'Update' => $_SESSION['vdUpdate'],
'Delays' => $_SESSION['esDelays'],
'timelargeH' => $_SESSION['timeLargeH'],
'timelargeM' => $_SESSION['timeLargeM'],
'LastLogin' => $_SESSION['LastLogin'],
'LastAction' => $_SESSION['LastAction'],
'LastSync' => $_SESSION['LastSync']
);
}else{
// RUN the MySQL Query, and load the contents into an array $config.
// I know this section is OK, as it was used prior to introducing SESSION variables
};
//AT The end of the page
$_SESSION['sendEmail'] = $config['sendEmail'];
$_SESSION['emailAddress'] = $config['emailAddress'];
$_SESSION['pageRefresh'] = $config['pageRefresh'];
$_SESSION['Update'] = $config['Update'];
$_SESSION['Delays'] = $config['Delays'];
$_SESSION['timeLargeH'] = $config['timeLargeH'];
$_SESSION['timeLargeM'] = $config['timeLargeM'];
$_SESSION['LastLogin'] = $config['LastLogin'];
$_SESSION['LastAction'] = $config['LastAction'];
$_SESSION['LastSync'] = $config['LastSync'];
$_SESSION['ConfRun'] = 0;