session_start() 仅适用于 Chrome [英] session_start() works only on Chrome

查看:43
本文介绍了session_start() 仅适用于 Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个很奇怪的问题.

I met very strange problem.

我有两个简单的 php 文件:testSession1.php:

I have two simple php files: testSession1.php:

<?
session_start();
$_SESSION['test'] = "Test here...";
?>
<a href="testSession2.php">Next</a>

testSession2.php:

testSession2.php:

<?
session_start();
print_r($_SESSION);
?>

在 Chrome 中我得到了预期的结果:

In Chrome i get the expected result:

Array ( [test] => Test here... )

但在 Mozilla 和 IE 中我只得到:

but in Mozilla and IE i get only:

Array()

请注意,我使用的所有浏览器都完全启用了 cookie.我很混乱...任何帮助将不胜感激.

Note that cookies are fully enabled on all the browsers i use. I'm so confused... Any help will be appreciated.

我用

session_set_cookie_params(3600, "/", "localhost", false, false);

所以这与我的 php.ini、vhosts 或 .htaccess 配置有关

So it is something with my php.ini, vhosts or .htaccess config

不幸的是 IE 继续拒绝设置会话 :(

Unfortunately IE continue to deny setting sessions :(

推荐答案

好的.这是我发现的:

使用:

session_set_cookie_params(3600, "/", "localhost", false, false);

我成功了,所以我怀疑 php.ini 配置错误.

i did the trick, so i suspected php.ini for missconfiguration.

在我的 php.ini 中更改这些设置后:

after change these settings in my php.ini:

session.save_path = "c:/temp"
session.cookie_secure = 0
session.cookie_httponly = 0
session.cookie_lifetime = 3600

重新启动我的 apache 后,它现在可以在所有浏览器上运行了.

After restarted my apache, it works now on all the browsers.

感谢您的时间.

这篇关于session_start() 仅适用于 Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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