PHP SESSION失效有关问题 !

WBOY
Libérer: 2016-06-13 10:35:05
original
1023 Les gens l'ont consulté

PHP SESSION失效问题 !!!
用CI写的腾讯登陆,需要存贮openId以及accessToken,
用Ajax

JScript code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->var xmlhttp;            if (window.XMLHttpRequest)            {// code for IE7+, Firefox, Chrome, Opera, Safari              xmlhttp=new XMLHttpRequest();            }            else            {// code for IE6, IE5              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");            }            xmlhttp.onreadystatechange=function()              {              if (xmlhttp.readyState==4 && xmlhttp.status==200)                {                        document.getElementById("myDiv").innerHTML=xmlhttp.responseText;                }              }                          if(QC.Login.check())/*QQ 登录*/            {                                        QC.Login.getMe(function(openId, accessToken){                            xmlhttp.open("GET","http://localhost/CI/index.php/SaveInfo/save_qq_openId?openId="+openId+"&accessToken="+accessToken,true);                            xmlhttp.send();                    });                                    }
Copier après la connexion


在SaveInfo/save_qq_openId控制器下 $_SESSION['openId'] = $_GET['openId'];

然后页面跳转到另一个控制器 echo $_SESSION['openId'];

错误提示 :
A PHP Error was encountered

Severity: Notice

Message: Undefined index: openId

Filename: controllers/ShopOnSale.php

Line Number: 125

查看过 php.ini 文件 没有问题 

在另个页面标签前写了也没有用
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php session_id('openId');session_start();?>
Copier après la connexion



------解决方案--------------------
if(isset($_GET['openId']))
$_SESSION['openId'] = $_GET['openId'];
------解决方案--------------------
两个页面都需要开启session_start(); ,你做了吗?

------解决方案--------------------
在SaveInfo/save_qq_openId控制器下 $_SESSION['openId'] = $_GET['openId'];
那么你在他之前 session_start() 了吗?

又,
session_id('openId');
session_start();
是错误的,请去掉
------解决方案--------------------
注意COOKIE的domain,是否跨二级域名使用。
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!