-
- $currentSessionID = session_id();
- session_id($currentSessionID );
Copy code
The following is the implementation code, which is divided into http and https parts.
1, http part:
-
- session_start();
- $currentSessionID = session_id();
- $_SESSION['testvariable'] = 'Session worked';
- $secureServerDomain = 'www.sjolzy.cn';
- $securePagePath = '/safePages/securePage.php'
- echo 'Click here to jump To HTTPS protocol';
- ?>
Copy code
2, HTTPS part
-
- $currentSessionID = $_GET['session'];
- session_id($currentSessionID);
- session_start();
- if (!emptyempty($_SESSION['testvariable'])) {
- echo $_SESSION['testvariable'];
- } else {
- echo 'Session did not work.';
- }
- ?>
Copy code
Instructions:
There is a bit of a security issue. The transmission of the session id is not encrypted and can be detected by sniffing, obtaining the session id and then obtaining the session data.
It is recommended to encrypt this ID.
|