$ _SESSION不会保留ldap $ link_identifier [英] $_SESSION doesn't keep the ldap $link_identifier

查看:82
本文介绍了$ _SESSION不会保留ldap $ link_identifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将ldap链接标识符存储到会话变量时,我遇到了会话变量的奇怪行为.为此,我创建了两个PHP代码段.

I encountered a strange behaviour of the session variable when storing the ldap link identifier to it. For that I have created two php snippets.

test1.php:

<?php
  session_start();
  $_SESSION['test']=ldap_connect('ldap://asc-OpenLDAP.asc.asc-syscon.de');
  echo $_SESSION['test'];
?>

输出:资源ID#2

到目前为止,一切都很好. 但是,当我尝试在第二页上使用$ _SESSION时,它突然具有错误的值.

So far everything is nice and fine. But then when I try to use $_SESSION on the second page it suddenly holds a wrong value.

test1.php:

<?php
  session_start();
  $_SESSION['test']=ldap_connect('ldap://asc-OpenLDAP.asc.asc-syscon.de');
  header('Location:test2.php');
?>

test2.php:

<?php
  session_start();
  echo $_SESSION['test'];
?>

输出: 0

为什么会这样?如何使其保持test1.php中的正确值?

Why is that so? How can I make it keep the correct value from test1.php?

期待您的帮助.

推荐答案

您无法在存储中存储Resource,因为会话数据在保存之前已序列化.阅读此 http://php.net/manual/zh/function.serialize.php

You cannot store Resource in storage, because session data is serialized before save. Read this http://php.net/manual/en/function.serialize.php

这篇关于$ _SESSION不会保留ldap $ link_identifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆