PHP:session.auto_start

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1378497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:16:42  来源:igfitidea点击:

PHP: session.auto_start

phpsession

提问by hhh

I have two projects in the same server, their settings conflict in the "session.auto_start", related post. Can I have the session.auto_start "ON" despite the other project contains codes such as session_start()?

我在同一台服务器上有两个项目,它们的设置在“session.auto_start”相关帖子中发生冲突。尽管其他项目包含诸如 session_start() 之类的代码,但我可以让 session.auto_start "ON" 吗?

回答by JasonWoof

If you're using apache, and have the right Options, you can enable session.auto_start with a .htaccess file containing this line: php_flag session.auto_start 1

如果您使用的是 apache,并且有正确的选项,则可以使用包含以下行的 .htaccess 文件启用 session.auto_start: php_flag session.auto_start 1

Or you might be able to put it in your global apache config in that tag.

或者您可以将它放在该标签中的全局 apache 配置中。

回答by Anthony

Do you need to independent sessions per user? I imagine you could just have one script check if a session already exists, like:

您是否需要为每个用户设置独立的会话?我想你可以只用一个脚本检查会话是否已经存在,例如:

if(!($_SESSION)) {
    session_start();
}

回答by ólafur Waage

If a session is already started. Then you will get an E_NOTICE error. session_start()docs.

如果会话已经开始。然后你会得到一个 E_NOTICE 错误。session_start()文档。

回答by Nikita

I think you have conflict not because of "session.auto_start" you just need to set individual session_namefor each project.

我认为你有冲突不是因为“session.auto_start”你只需要为每个项目设置单独的session_name