读取PHP的会话数据而不加载它

Meh*_*ran 4 php session

我有一个session_id,我想读取它的数据,而不将其加载到$_SESSION数组中.请记住,我没有将我的问题局限于某个特定的会话处理程序.

[UPDATE]

这是我的情景:

我有两个(或更多)不同的开源项目,我想合并为一个.这些项目使用会话,但它们相互覆盖是可行的(因为它们都在同一主机和同一域中).为了防止这种情况发生,我为每个设置了不同的session_names,因此他们将拥有自己的会话.但是我需要编写胶水代码,我必须能够访问这两个会话.我可以加载一个,$_SESSION但我必须阅读其他没有加载.

[UPDATE]

考虑到目前为止给出的答案,我想更多地澄清一些事情.我寻找的解决方案是在同一个请求中启动两次(或更多次)会话.并且每次使用不同的session_id.这样我就可以复制会话并加载另一个会话.有了这个说,没有必要唯一的解决方案,但它最接近我正在寻找的(只是一个提示).

Pet*_*arc 5

我将逐个启动两个会话并将$ _SESSION值存储在本地数组中.

// Loading the first session.
session_name('first_session_name');
session_start();
// Now we have first session variables available in $_SESSION
$_FIRST_SESSION = $_SESSION;
// End current session.
session_write_close();
// Just to make sure nothing remains in the session.
unset($_SESSION);
// Now set the second session name.
session_name('second_session_name');
// Check and see if the second session name has a session id.
if (isset($_COOKIE['second_session_name']))
    // There's already a session id for this name.
    session_id($_COOKIE['second_session_name']);
else
    // We need to generate a new session id as this is the first time.
    session_id(sha1(mt_rand()));
session_start();
$_SECOND_SESSION = $_SESSION;
Run Code Online (Sandbox Code Playgroud)