i am Roger Li

Codeigniter3 上遇到 「Message: ini_set(): A session is active. You cannot change the session module’s ini settings at this time」

近日在依照一個教學在Codeigniter3 上建立一個簡單的Login Form遇到點問題。

在所有的檔案都照着教學般建立後,開啟主頁面時便出現以下Error:

A PHP Error was encountered

Severity: Warning
Message: ini_set(): A session is active. You cannot change the session module’s ini settings at this time
Filename: Session/Session.php
Line Number: 314
Backtrace:

File: /home/content/xxx/codeigniter/ci317/application/controllers/User_authentication.php
Line: 17
Function: library
File: /home/content/xxx/codeigniter/ci317/index.php
Line: 315
Function: require_once
##############################

A PHP Error was encountered

Severity: Notice
Message: A session had already been started – ignoring session_start()
Filename: Session/Session.php
Line Number: 143
Backtrace:

File: /home/content/xxx/codeigniter/ci317/application/controllers/User_authentication.php
Line: 17
Function: library
File: /home/content/xxx/codeigniter/ci317/index.php
Line: 315
Function: require_once

##############################

原因是CI3 的Session Class重寫了並使用PHP原生的Session而該教學是以CI2來編寫的,當中一個檔案內有一句:

session_start();

所以大家會看到Error中提到」A session is active.」。

發表回覆

你的電郵地址並不會被公開。 必要欄位標記為 *