跳转到另一个现有会话(使用PHP的默认会话处理程序)

I have a scenario like this:

UserJoe has session_id abc123 abc123 is stored in UserJoe's row in the users table in the DB.

UserJoe calls AdminBob and reports a problem.

AdminBob needs to experience UserJoe's problem first hand

So, I'd like to do something like:

01|  $sessionId = getSessionId("UserJoe");
02|  changeToExistingSession($sessionId);
03|  if($_SESSION["name"] == "UserJoe") echo "successfully changed users";

Line 02 is where I'm kinda stuck... Any ideas?

(preferably not using session_save_path() anywhere :P)

EDIT: And it's just for the duration of the page execution. I'd like to keep AdminBob's session cookie intact.

If you store UserJoe's session ID in a database together with the report, then I think you can use session_id() to set AdminBob's session ID to UserJoe's session id.

<?php
  if(!isset($_GET["id"]))
  {
    session_start();
    $_SESSION["foobar"] = $_GET["bar"];
    echo "Setting...";
    var_dump($_SESSION);
    var_dump($_COOKIE);
  }
  else
  {
    session_id($_GET["id"]);
    var_dump($_GET["id"]);
    var_dump($_COOKIE);
    session_start();
    var_dump($_SESSION);
  }
?>

To test: Open this page in one browser and set bar to anything.

index.php?bar=blahblahblah

Open a new browser and visit the same page but do not set bar, get the value of PHPSESSID and set it as id's value

index.php?id=[value of PHPSESSID]

You should see the other browser's session in the newly opened browser