转移阿帕奇虚拟主机之间的会话数据 [英] Transfer Session Data Between Apache Virtual Hosts

查看:173
本文介绍了转移阿帕奇虚拟主机之间的会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何通过PHP会话数据从一个Apache的虚拟主机到另一个?我目前正在运行的Apache 2.2.17和5.3.3 PHP和我设置了一台主机来管理单点登录应用程序,我需要将此传递到运行不同的应用程序其他两个虚拟主机。这是我打算进一步发展,但目前传递会话数据将是最容易的。

How do I pass PHP session data from one Apache virtual host to another? I am currently running Apache 2.2.17 and PHP 5.3.3 and I've set up one host to manage a single sign-on application and I need to pass this to two other virtual hosts that are running separate applications. This is something I intend to develop further, but for now passing session data would be the easiest.

目前此code会在SSO子auth.domain.com第一届会议,然后通过用户返回到应用程序界面app.domain.com(已修整):

Currently this code creates the first session in the SSO subdomain auth.domain.com and then passes the user back to the application interface app.domain.com (has been trimmed):

  $user = new User;
  $user->set_user_session();
  Header("Location: $redirectURL");
  exit;

服务器完全由私人管理如此多用户的安全不是一个担心。但是,如果有人认为超出了任何安全问题请让我知道。如果你知道一个更好的方法欢迎交流,我将进一步研究它。我AP preciate的帮助。

The server is entirely managed privately so multi-user security isn't a worry. However, if anyone sees any security issues beyond that please let me know. If you know of a better methodology please share and I will research it further. I appreciate the help.

推荐答案

据我所知,PHP会话不是(默认)的虚拟主机知道:你需要传递会话ID作为部分重定向然后将其设置在其他的虚拟主机。因此,像:

As far as I'm aware, PHP sessions are not (by default) virtual-host aware: you would need to pass the session ID as part of the redirect and then set it in the other virtual host. So something like:

$sessionid = session_id();
Header("Location: $redirectURL?session=$sessionid");
exit;

然后在重定向的目标:

And then in the target of the redirect:

session_id($_GET['session']);
session_start();

试一下,让我知道它是如何工作的。

Try that and let me know how it works.

这篇关于转移阿帕奇虚拟主机之间的会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆