session_start() 不适用于 xampp
session_start() not working on xampp
我正在尝试使用 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.
出现问题的最可能原因是您将会话保存到默认文件夹,并在默认文件夹中安装了 xampp,并且配置文件中的session.save_path
可能指向session.save_path="C:'xampp'tmp"
在 C:'' 上安装 xampp 不是一个好主意重新安装它或编辑配置,将session.save_path更改为其他位置。
Session_start失败,因为缺少权限
编辑。
您的会话正在工作。创建新的.php文件以确保它。只输入以下代码,仅此而已:
<?php
session_start();
$_SESSION["qwerty"] = "123456" ;
echo $_SESSION["qwerty"];
?>
回声会返回123456吗?
这是 xampp 的问题。
尝试更改 xampp 的版本,它将起作用。
实际上,xampp中存在一个错误,尝试安装旧版本的xampp或使用wampp。
或者试试这个
在 php.ini 文件 (xampp/php/php.ini) 中检查
session.save_path
存在,并且可由运行 PHP 的用户写入。
尝试删除注释部分,不要放置任何空格:
<?php
session_start();
?>
我遇到了同样的问题。在php.imi中,选项"session.use_only_cookies"设置为0,当我将其更改为1时,一切正常
我遇到了同样的问题,我通过以下方式解决了它。在 php.ini 文件的 Apache Config 中,我将session.use_only_cookies
从 0 更改为 1。
我想提一下,以前由于phpmyadmin的问题,我不得不在config.inc中用$cfg['Servers'][$i]['auth_type'] = 'cookie'
替换$cfg['Servers'][$i]['auth_type'] = 'config'
.php
首先:确保根据 Apache 中需要的模块启用会话模块。
LoadModule session_module modules/mod_session.so
LoadModule session_cookie_module modules/mod_session_cookie.so
LoadModule session_crypto_module modules/mod_session_crypto.so
LoadModule session_dbd_module modules/mod_session_dbd.so
在 php 中.ini你的值应该看起来与此有些相似,并确保此目录存在 -> (c:''xampp''tmp):
session.save_handler=files
session.save_path="c:'xampp'tmp"
session.use_strict_mode=0 (This is not encouraged, but will help with testing)
session.use_cookies=1
session.use_only_cookies=1
session.name=PHPSESSID
session.auto_start=0
session.cookie_lifetime=0
session.cookie_path=/ (<- important setting)
session.serialize_handler=php
session.gc_probability=1
session.gc_divisor=1000
session.gc_maxlifetime=1440
session.cache_limiter=nocache
session.cache_expire=180
session.use_trans_sid=0
session.sid_length=26
session.trans_sid_tags="a=href,area=href,frame=src,form="
session.sid_bits_per_character=5
对于此错误 ->
www.example.com:443:0 server certificate does NOT include an ID which matches the server name
这通常意味着在 httpd-ssl.conf 或 httpd-vhosts.conf 中配置了不正确的虚拟主机,您介意发布这两个文件内容以查看吗?
- html5 drawImage适用于firefox,而不是chrome
- Jquery Ajax POST不工作.适用于GET
- 如何调试遗留的javascript代码(适用于IE,但在Google Chrome中不正常)
- .load()适用于window,而不是ID
- 使用Jquery更改css样式适用于id's、 不在课堂上
- 提交按钮不会;不适用于Chrome或Firefox,但适用于Internet Explorer
- 为什么 javascript 中的“btoa”编码适用于 20 位字符串而不是 20 位整数
- Javascript String to Date适用于Chrome,而不是FF或Safari
- Onchange,向上,向下箭头键适用于FF和Chrome,但在IE中不起作用
- .load() 适用于 IE 和 dreamweaver 预览版,但不能使用 opera 和 chrome
- 找不到适用于 Highcharts 的 JSON 数组语法
- 为什么在jQuery中使用focusout适用于Firefox,而使用addEventListener则不适用;t
- jQuery选择菜单验证器适用于FF和Chrome,但不适用IE
- 单选按钮'onclick'适用于Chrome和Firefox,但不适用IE
- JQuery ScrollTop适用于chrome,但不适用firefox
- window.opener.location.href适用于IE,但不适用Chrome或Safari
- Frame Busting buster不完全适用于IE
- Jquery touch punch适用于Chrome和Firefox,但不适用IE
- 背景更改仅适用于chrome+$.预加载不适用;不起作用
- JavaScript window.location.replace适用于Firefox,但不适用IE或Chrome