[英]Why PHP Session Destroyed?
I have this php code, 我有这个PHP代码,
<?php
session_start();
Print_r($_SESSION);
$_SESSION['value'] = 1;
Print_r($_SESSION);
?>
Why it Prints following, everytime when I refreshes the page.. 每次刷新页面时为什么打印以下内容..
Array
(
)
Array
(
[value] => 1
)
It should Print, 它应该打印,
Array
(
[value] => 1
)
Array
(
[value] => 1
)
I am using lighttpd
as http
Server on Fedora 14. 我在Fedora 14上使用lighttpd
作为http
服务器。
I read that running chown -R root:lighttpd /var/lib/php/
fixed the problem for others that were having the same issue. 我读到运行chown -R root:lighttpd /var/lib/php/
解决了其他有同样问题的问题。
Source: 资源:
http://masdeni.com/archives/6-Lighttpd-+-PHP-Session-Problem.html http://masdeni.com/archives/6-Lighttpd-+-PHP-Session-Problem.html
I would test to see if session_start()
returns true
(session started), for example: 我会测试看session_start()
返回true
(会话已启动),例如:
$is_session_started = session_start();
If $is_session_started == false
, then you have 1/2 your answer right there. 如果$is_session_started == false
,那么你的答案就是1/2。 The other 1/2 will lie in figuring out why it is not starting. 另外1/2会找出它为什么没有开始。 Per @Ryan above, check your session ini settings. 根据上面的@Ryan,检查您的会话ini设置。
If you are using cookies for storing the Session ID, make sure that you call session_start()
before printing/echoing/returning any other values to the browser. 如果您使用cookie存储会话ID,请确保在打印/回显/返回任何其他值到浏览器之前调用session_start()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.