PHP simple implementation of HTTP and HTTPS cross-domain sharing session Solution _php Tutorial

Source: Internet
Author: User
Tags session id

PHP simple implementation of HTTP and HTTPS cross-domain sharing session solution


This article mainly introduces PHP simple implementation of HTTP and HTTPS cross-domain sharing session solution, this article explains the relatively simple method, the need for friends can refer to the next

HTTP, HTTPS protocol session sharing to resolve cookie failure method: (perhaps 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 Case 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. ';

}

A bit of security issues, because the session ID transmission is not encrypted, others can sniff detect, get the session ID and then get your session data. So consider encrypting this ID if you have to.

A Magento station's cookie setting has been invalidated for many days, and the last awareness is that the HTTP and HTTPS cross-domains invalidate the cookie.

http://www.bkjia.com/PHPjc/1007652.html www.bkjia.com true http://www.bkjia.com/PHPjc/1007652.html techarticle php Simple implementation of HTTP and HTTPS cross-domain sharing session solution This article mainly introduces the PHP simple implementation of HTTP and HTTPS cross-domain sharing session solution, this article explains the method is relatively simple, need ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.