jjzjj

php - 致命 :error - session has already been started by session. 自动启动或 session_start()

coder 2024-04-24 原文

我正在使用 zend framwork 开发 Web 应用程序并在其中实现登录和注销编码。身份验证适配器运行良好。 问题是,在验证和检查身份后,它在地址栏中显示了正确的重定向 url,但页面显示错误而不是显示 View

这里是错误
fatal error :在 C:\Users\amrit\Zend\workspaces\DefaultWorkspace7\webDeveloper\library\Zend\中未捕获异常“Zend_Session_Exception”,消息“session 已经由 session.auto-start 或 session_start()”启动462行的Session.php

Zend_Session_Exception: session 已由 C:\Users\TranceServe\Zend\workspaces\DefaultWorkspace7\webDeveloper\library\Zend\Session.php 中的 session.auto-start 或 session_start() 在第 462 行启动
当我单击刷新时,它显示了正确的 View 。注销代码运行良好。

这是我的 zend 代码

public function adminloginAction ()
{
    $login = new Admin_Form_Login();
    $login->setAction("adminlogin");
    $login->setMethod("POST");
    if (isset($_SESSION)) {
        echo ("start");
      } else {
        echo ("not started");
    }
    if ($this->_request->isPost() && $login->isValid($_POST)) {
        $adapter = new webDeveloper_Auth_StaffAdapter(
        $this->getRequest()->getParam("email"), 
        ($this->getRequest()->getParam("pwd")));
        $result = Zend_Auth::getInstance()->authenticate($adapter);
        if (Zend_Auth::getInstance()->hasIdentity()) {
           $this->_redirector->gotoUrl('/admin/index');
        } else {
            $this->_redirector->gotoUrl('/admin/adminauthentication/adminlogin');
        }
    }
    $this->view->form = $login;
}

最佳答案

当 zend_tool 用于创建项目时,它会将以下行添加到 application/configs/application.ini 文件中:

resources.session.save_path = APPLICATION_PATH "/../data/session"

检查此路径是否存在并且可由应用程序写入。否则,Zf 将向您发送带有此虚假消息的异常。

关于php - 致命 :error - session has already been started by session. 自动启动或 session_start(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6716241/

有关php - 致命 :error - session has already been started by session. 自动启动或 session_start()的更多相关文章

随机推荐