선택적 세션 시작 + 서드파티 자료 호환성 (Proof of Concept)

This commit is contained in:
Kijin Sung 2015-07-10 16:05:46 +09:00
parent 6745497ad7
commit 23a83a7033
5 changed files with 88 additions and 18 deletions

View file

@ -154,6 +154,12 @@ class Context
*/
public $isSuccessInit = TRUE;
/**
* Session status
* @var bool FALSE if session was not started
*/
public $isSessionStarted = FALSE;
/**
* returns static context object (Singleton). It's to use Context without declaration of an object
*
@ -333,8 +339,27 @@ class Context
);
}
if($sess = $_POST[session_name()]) session_id($sess);
session_start();
// start session if it was previously started
$session_name = session_name();
$session_id = NULL;
if($session_id = $_POST[$session_name])
{
session_id($session_id);
}
else
{
$session_id = $_COOKIE[$session_name];
}
if($session_id !== NULL)
{
$this->isSessionStarted = TRUE;
session_start();
}
else
{
$_SESSION = array();
}
// set authentication information in Context and session
if(self::isInstalled())
@ -420,6 +445,26 @@ class Context
}
}
/**
* Start the session if $_SESSION was touched
*
* @return void
*/
function checkSessionStatus()
{
if($this->isSessionStarted)
{
return;
}
if(count($_SESSION))
{
$tempSession = $_SESSION;
session_start();
$_SESSION = $tempSession;
$this->isSessionStarted = TRUE;
}
}
/**
* Finalize using resources, such as DB connection
*
@ -942,7 +987,10 @@ class Context
$self->lang_type = $lang_type;
$self->set('lang_type', $lang_type);
$_SESSION['lang_type'] = $lang_type;
if($this->isSessionStarted)
{
$_SESSION['lang_type'] = $lang_type;
}
}
/**