$ _SESSION超过两页+页面 [英] $_SESSION over two + pages

查看:97
本文介绍了$ _SESSION超过两页+页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想让$ _SESSION在我的网站上工作。为了更好地理解这一点,我更好地构建了两个非常简单的测试页面,看看我是否可以在两个页面上访问$ _SESSION。


Page 1

[PHP]

<?php / *创建日期:03/07/2007 * /

session_start();?>

< html>

< body>

<?php

$ _SESSION [''item1''] =" First会话变量" ;;

echo $ _SESSION [''item1''];

echo''< br /> < a href =" session2.php">点击这里< / a>'';


?>

< / body>

< / html> ;

[/ PHP]


这会正确显示$ _SESSION [''item1''],链接会将您带到第二页。 />

Page 2

[PHP]

<?php / *创建日期:03/07/2007 * /

session_start();?>

< html>

< body>

<?php

echo''我的第一个变量:''。 $ _SESSION [ ITEM1’ ];

?>

< / body>

< / html>

[/ PHP]


然而,这只显示基本文本,$ _SESSION [''item1'']没有任何内容。


我真的对于这个想法,我需要了解这是为了让我正在开发的网站正确地进行交互。


有人能看到这个简单的例子中缺少什么吗?


干杯

nathj

Hi,

I am trying to get $_SESSION to work on my site. In order to learn this an dunderstand it better I have built two very simple test pages to see if i can access $_SESSION on both pages.

Page 1
[PHP]
<?php /* Created on: 03/07/2007 */
session_start();?>
<html>
<body>
<?php
$_SESSION[''item1''] = "First session variable";
echo $_SESSION[''item1''];
echo ''<br /> <a href="session2.php"> click here </a>'';

?>
</body>
</html>
[/PHP]

This displays the $_SESSION[''item1''] correctly and the link takes you to the second page.

Page 2
[PHP]
<?php /* Created on: 03/07/2007 */
session_start();?>
<html>
<body>
<?php
echo ''My first variable: '' . $_SESSION[''item1''];
?>
</body>
</html>
[/PHP]

This however, only displays the basic text and nothing comes out from the $_SESSION[''item1''].

I am really ew to this idea and I need to understand this is order to get the site I am developing to be properly interactive.

Can anybody see what am missing with this simple example?

Cheers
nathj

推荐答案

_SESSION在我的网站上工作。为了更好地理解这一点,我更好地构建了两个非常简单的测试页面,看看我是否可以在两个页面上访问
_SESSION to work on my site. In order to learn this an dunderstand it better I have built two very simple test pages to see if i can access


_SESSION。


Page 1

[PHP]

<?php / *创建日期:03/07/2007 * /

session_start(); ?>

< html>

< body>

<?php
_SESSION on both pages.

Page 1
[PHP]
<?php /* Created on: 03/07/2007 */
session_start();?>
<html>
<body>
<?php

_SESSION [''item1''] ="第一个会话变量" ;;

echo
_SESSION[''item1''] = "First session variable";
echo


这篇关于$ _SESSION超过两页+页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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