HTTP和HTTPS跨域共享session解决办法 05 September 2011 10:16 Monday by 小屋 浏览(1658)

HTTP、HTTPS协议下session共享解决cookie失效 的办法:(也许不是最好的,但是实用)

原理就是把session id设置到本地的cookie,

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

简单事例代码:

(HTTP)

session_start(); 
$currentSessionID = session_id(); 
$_SESSION['testvariable'] = 'Session worked'; 
$secureServerDomain = 'www.sjolzy.cn'; 
$securePagePath = '/safePages/securePage.php' 
echo '<a href="https://' . $secureServerDomain . $securePagePath . '?session="' . $currentSessionID . '">点击这里跳转到HTTPS 协议下</a>';

阅读全文>>