php中http与https跨域共享session的解决方法
《:php中http与https跨域共享session的解决方法》要点: 遇到了HTTP、HTTPS协议下session共享解决cookie失效的问题,这里提供一个临时解决办法. 如下:PHP教程
代码如下:
$currentSessionID = session_id(); session_id($currentSessionID ); 以下是实现代码,分为http与https两部分.PHP教程 1,http部分:PHP教程
代码如下:
<?php session_start();? $currentSessionID = session_id();? $_SESSION['testvariable'] = 'Session worked';? $secureServerDomain = 'www.aspzz.cn';? $securePagePath = '/safePages/securePage.php'? echo '<a href="https://' . $secureServerDomain . $securePagePath . '?session="' . $currentSessionID . '">点这里跳转到HTTPS 协议</a>'; ?> 2,HTTPS部分PHP教程
代码如下:
<?php $currentSessionID = $_GET['session']; session_id($currentSessionID); session_start(); if (!emptyempty($_SESSION['testvariable'])) { ????? echo $_SESSION['testvariable']; } else {? ????? echo 'Session did not work.'; } ?> 说明: 《:php中http与https跨域共享session的解决方法》是否对您有启发,欢迎查看更多与《:php中http与https跨域共享session的解决方法》相关教程,学精学透。编程之家 52php.cn为您提供精彩教程。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |