张耳朵 发表于 2016-11-12 21:37:18

【新人求助】session问题

在写一个登陆的页面,刚把controller写了一点,load各种帮助类库和view,想先测一下这个目录下能不能显示,没想到碰到session问题
代码:
public function __construct()
{
    parent::__construct();
    session_start();
    $this->load->helper('form');
    $this->load->library('form_validation');
    $this->load->library('session');

    $this->load->model('login_database');

}打开页面报错:A PHP Error was encounteredSeverity: WarningMessage: ini_set(): A session is active. You cannot change the session module's ini settings at this timeFilename: Session/Session.phpLine Number: 316Backtrace:File: E:\workspace\php\application\controllers\authentication\user_authentication.php
Line: 17
Function: library

A PHP Error was encounteredSeverity: NoticeMessage: A session had already been started - ignoring session_start()Filename: Session/Session.phpLine Number: 143Backtrace:File: E:\workspace\php\application\controllers\authentication\user_authentication.php
Line: 17
Function: library
用的是CI3,在网上google了一下,说是去掉session_Start,可是去掉之后还是会报错,A PHP Error was encounteredSeverity: WarningMessage: mkdir(): Invalid pathFilename: drivers/Session_files_driver.phpLine Number: 136
An uncaught Exception was encounteredType: ExceptionMessage: Session: Configured save path '' is not a directory, doesn't exist or cannot be created.Filename: E:\workspace\php\system\libraries\Session\drivers\Session_files_driver.phpLine Number: 138
不知道怎么解决,求大佬帮助!

Hex 发表于 2016-11-12 21:53:41

不要自己写 session_start();
去掉 session_start() 后需要配置一下 CI session 的 PATH,看下 config.php 里~

张耳朵 发表于 2016-11-13 10:12:02

Hex 发表于 2016-11-12 21:53
不要自己写 session_start();
去掉 session_start() 后需要配置一下 CI session 的 PATH,看下 config.php...

谢大神!把session_save_path设成sys_get_temp_dir()就正常了,虽然不知道这是啥意思。。。

张耳朵 发表于 2016-11-13 10:16:08

Hex 发表于 2016-11-12 21:53
不要自己写 session_start();
去掉 session_start() 后需要配置一下 CI session 的 PATH,看下 config.php...

还想问一下hex大神,如果在controller里建了一个子目录,在里面新建controller的话,在route.php里的默认路由直接设置成 子目录/controller文件名就可以吗?为什么我这么设置会报404错误呢?

Hex 发表于 2016-11-13 11:27:06

张耳朵 发表于 2016-11-13 10:16
还想问一下hex大神,如果在controller里建了一个子目录,在里面新建controller的话,在route.php里的默认 ...

不可以,默认路由不支持子目录。
页: [1]
查看完整版本: 【新人求助】session问题