PHP 会话在 PHP5 中不起作用 [英] PHP Session not working in PHP5

查看:64
本文介绍了PHP 会话在 PHP5 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个页面:login.php 和 index.php.两个页面都以

I have 2 pages: login.php and index.php. Both pages start with

session_start();

当我设置

$_SESSION['user'] = "name"; 

在 login.php 中,然后打开 index.php,我的会话对象是空的.怎么来的?

in login.php and than open index.php, my session object is empty. How come?

我发现了问题:IE 7.我必须访问我的域.但是,我认为会话存储在服务器上,而不是客户端上?为什么我可以 IE 访问我的域?(http://www.pcwindowstips.com/2007/09/04/how-to-enable-cookies-in-internet-explorer-7/)

I found the problem: IE 7. I had to grand access to my domain. However, I thought a session is stored on the server, instead of the client? Than why do I have IE grand access to my domain? (http://www.pcwindowstips.com/2007/09/04/how-to-enable-cookies-in-internet-explorer-7/)

推荐答案

我认为会话存储在服务器上,而不是客户端上?为什么我有 IE 授予访问我的域的权限?(http://www.pcwindowstips.com/2007/09/04/how-to-enable-cookies-in-internet-explorer-7/)

会话的工作方式是为站点存储一个会话 cookie,其中包含您的会话 ID.服务器知道您是谁的唯一方法是在每次加载页面时读取会话 ID cookie.所有 $_SESSION 数据都存储在每个用户的服务器上,但必须设置 cookie 以便服务器知道要检索哪些 $_SESSION 数据.

The way sessions work is that a session cookie is stored for the site, which contains your session ID. The only way the server knows who you are is when it reads the session ID cookie on every page load. All of the $_SESSION data is stored on the server for each user, but the cookie must be set for the server to know which $_SESSION data to retrieve.

这也是为什么如果您获得他们的会话 ID cookie,您基本上可以成为"另一个用户.

This is also why you can essentially "become" another user if you obtain their session id cookie.

这篇关于PHP 会话在 PHP5 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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