数组作为会话变量 [英] Array as session variable

查看:110
本文介绍了数组作为会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时有可能使一个数组PHP中的会话变量。的情况是,我有有一个链接到一个特定页面的一些细胞的表(第1页)。下一个页面有名字(第2页,我想保持在一个会话阵列)各自的复选框的列表。在提交此表,这将导致交易页面(第3页,在这里贴复选框值都保存在一个数据库中对应的名称)。现在,如果我回到第一页,然后点击另一个单元格,将在本届会议阵列包含姓名或旧的新的列表?

Is it possible to make an array a session variable in PHP. The situation is that I have a table (page 1) with some cells having a link to a particular page. The next page will have a list of names (page 2, which I want to keep in a session array) with their respective checkboxes. On submitting this form, it will lead to a transaction page (page 3, where values of posted checkboxes are kept in a database for corresponding names). Now, if I return to the first page and click another cell, will the session array contain the new list of names or the old ones?

推荐答案

是,PHP支持数组作为会话变量。见<一href=\"https://web.archive.org/web/20080707052007/http://www.phpriot.com/articles/intro-php-sessions/7\">this页面一个例子。

Yes, PHP supports arrays as session variables. See this page for an example.

至于你的第二个问题:一旦你设置会话变量,它会保持不变,直到您更改或 取消设置 它。因此,如果第3页不改变会话变量,它会保持不变,直到第2页再次改变它。

As for your second question: once you set the session variable, it will remain the same until you either change it or unset it. So if the 3rd page doesn't change the session variable, it will stay the same until the 2nd page changes it again.

这篇关于数组作为会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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