我调用 session

编程入门 行业动态 更新时间:2024-10-12 03:22:38
本文介绍了我调用 session_start() 脚本挂起,没有任何反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在运行 php5,但是一旦我调用 session_start() 脚本挂起,什么也没有发生.有没有其他人遇到这个问题,或者我做错了什么吗?

I am running php5, however as soon as I call session_start() the script hangs and nothing happens. Is anyone else experiencing this problem, or am I doing something incorrectly?

我在 index.php 上使用 session_start() 有时出于某种原因它会失败.没有警告,没有错误,没有通知,甚至没有前置 error_reporting(E_ALL) 和 ini_set('display_errors', TRUE)在 session_start() 之前我看到任何东西,它只是简单地死亡.

I am using session_start() on index.php and for some reason sometimes it'll fail. No warnings, no errors, no notices, not even after prepending error_reporting(E_ALL) and ini_set('display_errors', TRUE) before session_start() do I see anything, it just plain dies.

推荐答案

造成这种情况的原因有很多,这里列举几个:

There are many reasons for that, here are a few of them:

A.会话文件可以以独占方式打开.当文件锁由于某种原因没有正确释放时,它会导致 session_start() 在任何未来的脚本执行中无限挂起.解决方法:使用 session_set_save_handler() 并确保写入函数使用 fopen($file, 'w') 而不是 fopen($file, 'x')

A. The session file could be opened exclusively. When the file lock is not released properly for whatever reason, it is causing session_start() to hang infinitely on any future script executions. Workaround: use session_set_save_handler() and make sure the write function uses fopen($file, 'w') instead of fopen($file, 'x')

B.切勿在 php.ini 文件中使用以下内容(熵文件到/dev/random"),这会导致 session_start() 挂起:

B. Never use the following in your php.ini file (entropie file to "/dev/random"), this will cause your session_start() to hang:

<?php ini_set("session.entropy_file", "/dev/random"); ini_set("session.entropy_length", "512"); ?>

C.session_start() 需要一个目录来写入.

C. session_start() needs a directory to write to.

您可以在普通用户帐户中运行 Apache 和 PHP.当然,Apache 将不得不侦听 80 以外的其他端口(例如 8080).

You can get Apache plus PHP running in a normal user account. Apache will then of course have to listen to an other port than 80 (for instance, 8080).

请务必做到以下几点:- 创建一个临时目录 PREFIX/tmp- 将 php.ini 放在 PREFIX/lib 中- 编辑 php.ini 并将 session.save_path 设置为刚刚创建的目录

Be sure to do the following things: - create a temporary directory PREFIX/tmp - put php.ini in PREFIX/lib - edit php.ini and set session.save_path to the directory you just created

否则,您的脚本似乎会在 session_start() 上挂起".

Otherwise, your scripts will seem to 'hang' on session_start().

更多推荐

我调用 session

本文发布于:2023-11-12 21:36:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582588.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:session

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!