PHP implements the HTTP and HTTPS cross-domain sharing session solution, httpssession. PHP implements simple HTTP and HTTPS cross-domain sharing session solutions. httpssessionHTTP and HTTPS protocol session sharing solves cookie failure: (maybe not the best, but practical) PHP implements the HTTP and HTTPS cross-domain sharing session solution, httpssession
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 ..
Protocol HTTP and HTTPS protocol session sharing solution for cookie failure: (maybe not the best, but practical )...