PHP:$ _SESSION从未设置,但是$ _POST是? [英] PHP: $_SESSION never getting set, but $_POST is ?
问题描述
[@下注和白痴的言论,这对打败人们不是很酷.我花了整整3天的时间重新检查了文档和课程笔记,甚至还没有提出问题-. 像詹姆斯一样,关闭此按钮可防止出现一群白痴,堆满了无用且实际上是不正确的评论.感谢Charles和Brent B的帮助. 原来这不是Safari的问题,所以我删除了这些标签.]
[@the downvote and idiot remarks, that's not cool to beat up on people. I rechecked the documentation and coursenotes for 3 whole days before even asking the question - . Closing this to prevent a chorus of idiots piling on with useless and factually incorrect comments, as James did. Thanks to Charles and Brent B for being very helpful. This turns out not to be a Safari issue so I removed those tags.]
$ _ SESSION没有在Safari中设置,因此我的多页表单中断了. $ _POST,$ _ REQUEST确实被设置了(但显然在随后的页面上消失了). 版本是PHP:5.3.1,Safari 5.
$_SESSION is not getting set in Safari, and hence my multipage form breaks. $_POST, $_REQUEST do get set (but obviously disappear on subsequent pages). Versions are PHP: 5.3.1, Safari 5.
帮助!下列任何一项不是不是问题,我都进行了检查,并阅读了所有其他相关问题:
Help! It is not an issue with any of the following, I checked them all, and I read all the other related questions:
- session_start()有效. SID/PHPSESSID在页面之间保留.
- session.use_cookies = 1,session.use_only_cookies = 1
- 我检查了 php.ini 并认为一切正常
- 我确实将Safari配置为接受所有cookie(目前).没什么.
- 我可以手动设置 $ _ SESSION ['debug'] ,并且确实会保留在整个页面中(并且会话文件已正确写出).除非我这样做,否则永远不会定义 $ _ SESSION .
- session_start() works. SID/PHPSESSID is preserved across pages.
- session.use_cookies = 1, session.use_only_cookies = 1
- I checked php.ini and believe it to be ok
- I did configure Safari to accept All cookies (for now). No difference.
- I can manually set $_SESSION['debug'] and that does get preserved across pages (and the session file is correctly written out). Unless I do that, $_SESSION never gets defined.
我没有时间调试这种废话,因此,以下哪种最新的变通办法是最丑陋的? (这是编程任务,而不是生产代码) 根据课程说明,$ _ SESSION应该合并$ _POST,$ _ REQUEST,$ _ GET,session和globals对吗?
I don't have time to debug this nonsense, so which of the following last-minute workarounds is the least ugly? (this is a programming assignment, not production code) According to course notes , $_SESSION is supposed to merge $_POST, $_REQUEST, $_GET, session and globals right?
- 手动执行 $ _ SESSION = array_merge($ _ SESSION,$ _ POST); [有效]
- 使用隐藏的表单在后续表单上重新发布 $ _ POST
- 其他?
- manually do $_SESSION = array_merge($_SESSION,$_POST); [this works]
- use hidden form to re-post $_POST on subsequent forms
- other?
(更广泛地说,应该简单地认为PHP在Safari(5)上已被破坏吗?)
(On a wider note, should PHP simply be considered broken on Safari (5)?)
推荐答案
$ _ SESSION不会合并其他超级全局数组,因为它是自己的数组. $ _REQUEST是$ _POST和$ _GET的合并,仅此而已.根据您的描述,$ _ SESSION工作正常.阅读官方手册. http://www.php.net/manual/en/language.variables .superglobals.php
$_SESSION does NOT merge other super global arrays, it is it's own array. $_REQUEST is a merge of $_POST and $_GET, but that's about it. From what you describe, $_SESSION is working properly. Read the official manual. http://www.php.net/manual/en/language.variables.superglobals.php
这篇关于PHP:$ _SESSION从未设置,但是$ _POST是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!