输入banner图图片脚本导航/分类

HTTP和HTTPS跨域共享phpsession方法

HTTP、HTTPS协议下跨域解决php session共享的办法,也许不是最好的,但是比较实用。

如下是具体的解决方案。

$currentSessionID=session_id();session_id($currentSessionID);

简单示例代码:

(HTTP)

session_start();

$currentSessionID=session_id();

$_SESSION['username']='scutephp';

echo '点击这里跳转到HTTPS协议下';

(HTTPS)

$currentSessionID=$_GET['session'];

session_id($currentSessionID);

session_start();

if(!empty($_SESSION['username'])){

echo $_SESSION['username'];

}else{

echo 'Session did not work.';

}

有点安全性的问题,因为这样子的话session id的传输是没加密的,别人可以嗅探侦测到,获取这个session id进而获取你的session数据。所以有必要的话可以考虑加密这个id值。