HTTP and HTTPS cross-domain shared session resolution

Source: Internet
Author: User
Tags session id domain

The method of resolving session sharing across domains under HTTP and HTTPS protocols may not be the best, but it is more practical. The following are the specific solutions.

$currentSessionID =session_id ();
session_id ($currentSessionID);

Simple Sample code:

(HTTP)

<?php
session_start ();  
$currentSessionID =session_id ();  
$_session[' username ']= ' alixixi ';  
Echo ' <a href= "https://www.Alixixi.com/jquery.php?session=" '. $currentSessionID. ' " > Click here to jump to the HTTPS protocol </a> ';

(HTTPS)

<?php
$currentSessionID =$_get[' Session '];
session_id ($currentSessionID);
Session_Start ();
if (!empty ($_session[' username ')) {
      echo $_session[' username '];
} else{  
      Echo ' session did not work. ';
}

A little security problem, because such a Word session ID transmission is not encrypted, others can sniff detect, get this session ID and then get your session data. So you can consider encrypting this ID value if necessary. On the encryption aspects of the article can refer to this site:

PHP Encryption and decryption function

Articles that you may be interested in

    • Common HTTP Status Code (HTTP status Code) description
    • PHP Custom Session Save Directory
    • XDebug's progress bar stops at 57%, prompting waiting for XDebug session error resolution
    • PHP implementation of the same server with multiple two-level domain share session data
    • jquery gets a collection of peer elements, jquery siblings usage Summary
    • PHP gets the method for each month over a period of time, returning an array of these months
    • PHP uses the P3P header to implement a cross domain cookie
    • How to troubleshoot PHP run appears call to undefined function Curl_init error


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.