isset($ _SESSION [])和MySQL请求

时间:2014-02-11 16:18:24

标签: php mysql session session-variables session-state

我想在没有定义会话时创建会话。当我在MYSQL上更新我的网站表时,我有一个已定义的会话,我不想看到新的数据。我也不想向DB请求。但是下面的代码给我带来了DB的新数据。 site_title是<title>$SITE_TITLE</title>

if ( isset($_SESSION["SESSION_AVAIABLE"]) == FALSE ) {
$_SESSION["SESSION_AVAIABLE"] =TRUE;

//fetch 
$site_info = $central_db->query("SELECT * FROM sites WHERE site_id = 100 ");
$site_info->setFetchMode(PDO::FETCH_ASSOC);
$site_data = $site_info->fetch();

//create sessions
$_SESSION["site_title"] = $site_data["site_title"];
$SITE_TITLE = $_SESSION["site_title"];

$_SESSION["site_description"] = $site_data["site_description"];
$SITE_DESC = $_SESSION["site_description"];

var_dump(isset($_SESSION["SESSION_AVAIABLE"]));
}

else {
 echo "sessions are avaiable";
 }

0 个答案:

没有答案