PHPでhttpとhttpsでセッション同期共有の解決方法

解決対策:
$currentSessionID=session_id();
session_id($currentSessionID);

PHPコード
1.http
session_start();
$currentSessionID=session_id();
$_SESSION['username’]=’phpsession_startnews24′;
echo '<a href="https://www.XXX.com/redir.php?session="'.$currentSessionID.'">httpsページに遷移</a>’;

2.https
$currentSessionID=$_GET['session’];
session_id($currentSessionID);
session_start();
if(!empty($_SESSION['username’])){
echo $_SESSION['username’];
}else{
echo 'セッションが動作しません.’;
}
注意:
セッションID送信を暗号化されていないためセキュリティ問題があります。
session idの値を暗号化することが必要です。

PHP

Posted by arkgame