简体   繁体   English

session_start()在xampp上不起作用

[英]session_start() not working on xampp

I am trying to start a session using session_start() function. 我正在尝试使用session_start()函数启动会话。 I am using xampp's server. 我正在使用xampp的服务器。 But whenever I include this code, the page doesn't load. 但是,每当我包含此代码时,页面都不会加载。 If I remove this code, the page loads perfectly. 如果删除此代码,该页面将完美加载。 Is it a problem with xampp? xampp有问题吗? This is the code placed at the very beginning of the file without any whitespaces before php tag. 这是放置在文件开头的代码,php标记前没有任何空格。

<?php
// Start the session
session_start();
?>

Can somebody help me with this? 有人可以帮我吗?

This is what Apache log says : 这就是Apache日志所说的:

[Fri Mar 04 19:13:09.822907 2016] [mpm_winnt:notice] [pid 5444:tid 508] AH00428: Parent: child process 7200 exited with status 3221225477 -- Restarting.
[Fri Mar 04 19:13:10.738482 2016] [ssl:warn] [pid 5444:tid 508] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Mar 04 19:13:10.800485 2016] [mpm_winnt:notice] [pid 5444:tid 508] AH00455: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.0 configured -- resuming normal operations
[Fri Mar 04 19:13:10.800485 2016] [mpm_winnt:notice] [pid 5444:tid 508] AH00456: Apache Lounge VC14 Server built: Dec  9 2015 10:17:39
[Fri Mar 04 19:13:10.800485 2016] [core:notice] [pid 5444:tid 508] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Mar 04 19:13:10.805024 2016] [mpm_winnt:notice] [pid 5444:tid 508] AH00418: Parent: Created child process 5404
[Fri Mar 04 19:13:12.067176 2016] [ssl:warn] [pid 5404:tid 532] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Mar 04 19:13:12.337492 2016] [ssl:warn] [pid 5404:tid 532] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Mar 04 19:13:12.400429 2016] [mpm_winnt:notice] [pid 5404:tid 532] AH00354: Child: Starting 150 worker threads.

It is a problem of xampp. 这是xampp的问题。

Try to change version of xampp and it will work. 尝试更改xampp的版本,它将起作用。

Actually there is a bug in xampp try to install older version of xampp or use wampp. 实际上,xampp中存在一个错误,请尝试安装较早版本的xampp或使用wampp。

or try this 或尝试这个

Check that in php.ini file (xampp/php/php.ini) 检查php.ini文件(xampp / php / php.ini)中的内容

session.save_path 

exists and is writeable by the user under which PHP is running. 存在并且可由运行PHP的用户编写。

The most probable cause of your problem is you save session to default folder with xampp installed in default folder and session.save_path in your config file probably points to session.save_path="C:\\xampp\\tmp" 你的问题的最可能的原因是你保存会话默认的文件夹与安装在默认的文件夹和XAMPP session.save_path在你的配置文件可能指向session.save_path="C:\\xampp\\tmp"

It's not a good idea to install xampp on C:\\ reinstall it or edit config changing the session.save_path to a different location. 将xampp安装在C:\\上或重新配置配置以将session.save_path更改为其他位置不是一个好主意。

Session_start failing because lack of permissions 由于缺少权限,Session_start失败

EDIT. 编辑。

Your session is working. 您的会话正在运行。 Create new .php file to make it sure. 创建新的.php文件以确保确定。 Put inside only the following code and nothing more than that: 仅放入以下代码,仅此而已:

<?php
session_start();
$_SESSION["qwerty"] = "123456" ;
echo $_SESSION["qwerty"];
?>

Does the echo return 123456? 回声是否返回123456?

Try remove the commented section and don't put any space : 尝试删除注释部分,不要留任何空格:

<?php
  session_start();
?>

I had same problem. 我有同样的问题。 In php.imi option "session.use_only_cookies" was set to 0, when I changed it to 1 everything worked fine 在php.imi选项中,将“ session.use_only_cookies”设置为0,当我将其更改为1时,一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM