实现多域名下共用一个SESSION[转]

<?php
class mdSession
{
/*

使用:
服务器A,服务器B,在A的index.php登陆,在B里建立一个接收SESSION的文件,例如ses_get.php
A的index.php做如下修改
最开始加上session_start();
<body></body>里,任意一个地方写上:mdSession::_set('B/ses_get.php')
而ses_get.php则在开头写上mdSession::_get();
@作者:[email protected] http://www.surfchen.org/
*/
function mdSession()
{

}
function set($urls)
{
if (!is_array($urls))
{
$urls=array($urls);
}
foreach ($urls as $value)
{
echo '<span style="position:absolute;visibility:hidden"><iframe src="'.$value.'?'.session_id().'"></iframe></span>';
}
return true;
}
function get()
{
session_id($_SERVER['QUERY_STRING']);
session_start();
return true;
}
function _set($urls)
{
$obj=new mdSession();
return $obj->set($urls);
}
function _get()
{
$obj=new mdSession();
return $obj->get();
}
}
?>

猜你喜欢

转载自201111055942.iteye.com/blog/1545399