深圳全飞鸿
标题:
Radphp的session处理
[打印本页]
作者:
zhgc
时间:
2020-9-2 13:41
标题:
Radphp的session处理
restore_session 用于清空
/**
* Shutdown function, called by the PHP engine as the last thing to do before shutdown.
*
* This function is automatically called by the PHP engine just before shutdown, and it's the right moment to serialize
* all components as no more user code is going to be executed.
*
* This way, the status of all objects in the aplication is stored to be recovered later without user intervention.
*
* @see Application::serializeChildren()
* @link [url]http://www.php.net/manual/en/function.register-shutdown-function.php[/url]
*
*/
function RPCLShutdown()
{
global $application;
//This is the moment to store all properties in the session to retrieve them later
$application->serializeChildren();
//Uncomment this to get what is stored on the session at the last step of your scripts
/*
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
*/
}
复制代码
作者:
zhgc
时间:
2020-9-2 13:46
class Application extends Component
function __construct($aowner=null)
{
parent::__construct($aowner);
global $startup_functions;
//Call all startup functions before create the session
reset($startup_functions);
while(list($key, $val)=each($startup_functions))
{
$val();
}
if(!isset($_SESSION))
{
if (!session_start()) die ("Cannot start session!");
}
if (isset($_GET['restore_session']))
{
if (!isset($_POST['xajax']))
{
$_SESSION = array();
session_destroy();
if (!session_start()) die ("Cannot start session!");
}
}
//TODO: Check this for security issues
reset($_GET);
while (list($k,$v)=each($_GET))
{
if (strpos($k,'.')===false) $_SESSION[$k]=$v;
}
}
复制代码
作者:
zhgc
时间:
2020-9-2 13:48
function serialize()
{
$toserialize=array();
reset($this->components->items);
while (list($k,$v)=each($this->components->items))
{
$parent="";
if ($v->inheritsFrom('Control')) $parent=$v->parent->Name;
if ($v->Name!='') $toserialize[$v->Name]=array($parent,$v->className());
}
global $application;
$_SESSION['comps.'.$application->Name.'.'.$this->className()]=$toserialize;
//Store last resource read to prevent reloading again in the next post
$_SESSION[$this->readNamePath().'._reallastresourceread']=$this->reallastresourceread;
parent::serialize();
}
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2