php session_start()在xampp上不起作用

zbdgwd5y  于 2023-02-11  发布在  PHP
关注(0)|答案(5)|浏览(139)

我正在尝试使用session_start()函数启动一个会话。我使用的是xampp的服务器。但是每当我包含这段代码时,页面就不会加载。如果我删除这段代码,页面就会完美加载。这是xampp的问题吗?这段代码放在文件的最开始,php标记前没有任何空格。

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

有人能帮我一下吗?
这是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.
gcxthw6b

gcxthw6b1#

这是一个xampp的问题。
尝试更改xampp的版本,它将工作。
实际上,在xampp中有一个错误,尝试安装旧版本的xampp或使用wampp。
或者试试这个
在php.ini文件中检查(xampp/php/php.ini)

session.save_path

存在并且可由运行PHP的用户写入。

g52tjvyc

g52tjvyc2#

尝试删除评论部分,不要留下任何空间:

<?php
  session_start();
?>
cbjzeqam

cbjzeqam3#

问题最可能的原因是您将会话保存到默认文件夹,而xampp安装在默认文件夹中,并且配置文件中的session.save_path可能指向session.save_path="C:\xampp\tmp"
在C:\上安装xampp不是一个好主意,请重新安装它或编辑配置,将www.example.com_path更改为其他位置。session.save_path to a different location.
Session_start failing because lack of permissions
编辑。
您的会话正在工作。创建新的. php文件以确保它。只放入以下代码,除此之外别无其他:

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

回声是否返回123456?

ars1skjm

ars1skjm4#

我也遇到了同样的问题,在php.imi中,选项“session.use_only_cookies”被设置为0,当我把它改为1时,一切正常

wpx232ag

wpx232ag5#

我遇到了同样的问题,我用下面的方法解决了它:在Apache Config的php.ini文件中,我将session.use_only_cookies从0改为1。
我想提一下,之前因为phpmyadmin的问题,我不得不在config.inc.php中将$cfg['Servers'][$i]['auth_type'] = 'config'替换为$cfg['Servers'][$i]['auth_type'] = 'cookie'

相关问题