PHP provides a simple solution for cross-origin session sharing between HTTP and HTTPS. PHP simple implementation of HTTP and HTTPS cross-origin sharing session solution this article mainly introduces PHP simple implementation of HTTP and HTTPS cross-origin sharing session solution, the method described in this article is relatively simple, PHP is required for simple implementation of HTTP and HTTPS cross-domain sharing session solution
This article mainly introduces PHP's simple solution for implementing HTTP and HTTPS cross-domain sharing sessions. the method described in this article is relatively simple. For more information, see
Solution to cookie failure through session sharing over HTTP and HTTPS: (maybe not the best, but practical)
The principle is to set the session id to a local cookie,
The code is as follows:
$ CurrentSessionID = session_id ();
Session_id ($ currentSessionID );
Simple example code:
(HTTP)
The code is as follows:
Session_start ();
$ CurrentSessionID = session_id ();
$ _ SESSION ['testvariable'] = 'session worked ';
$ SecureServerDomain = 'www .sjolzy.cn ';
$ SecurePagePath = '/safePages/securePage. php'
Echo 'click here to jump to the HTTPS protocol ';
(HTTPS)
The code is as follows:
$ CurrentSessionID = $ _ GET ['session'];
Session_id ($ currentSessionID );
Session_start ();
If (! Emptyempty ($ _ SESSION ['testvariable']) {
Echo $ _ SESSION ['testvariable'];
} 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 if necessary.
The cookie settings of a magento site have been invalid for many days. The last thing I realized was that the cross-domain communication between HTTP and HTTPS invalidates the COOKIE ..
Ghost This article mainly introduces PHP's simple solution to implementing HTTP and HTTPS cross-domain sharing sessions. This article describes the method relatively simple and requires...