The solution to phpsession sharing under HTTP and HTTPS protocols may not be the best, but it is more practical. The following is a specific solution. $ CurrentSessionIDsession_id (); session_id ($ currentSessionID); simple sample code: (HTTP) & lt ;? Phpsession_start (); $ currentSessionIDsession_id (); & nbsp; $ _ SE cross-domain solutions for php session sharing under HTTP and HTTPS protocols may not be the best, but it is more practical.
The following is a specific solution.
$currentSessionID=session_id();session_id($currentSessionID);
Simple sample code:
(HTTP)
Session_start ();
$ CurrentSessionID = session_id ();
$ _ SESSION ['username'] = 'scutephp ';
Echo 'click here to jump to the HTTPS protocol ';
(HTTPS)
$currentSessionID=$_GET['session'];
session_id($currentSessionID);
session_start();
if(!empty($_SESSION['username'])){
echo $_SESSION['username'];
}else{
echo 'Session did not work.';
}
This is a bit of a security issue, because in this case, the session id is not encrypted, and others can sniff and detect it, get this session id, and then get your session data. You can encrypt this id value if necessary.