Welcome Guest, Not a member yet? Register   Sign In
"Unable to locate the specified class: Session.php"...
#1

Hi Guys,

After some years developing with CI i'm here to write about an issue i experiencing with v3.1.4

Starting with my code:

application/core
PHP Code:
class FF_Controller extends CI_Controller
{
 
   
    public 
function LoadView($view$data null)
 
   {
 
       $head_data = array();
 
       if(array_key_exists("title"$data)){
 
           $head_data["title"] = $data["title"];
 
       }

 
       $this->load->view("layout/_header"$head_data);
 
       $this->load->view("layout/_nav");
 
       $this->load->view($view$data);
 
       $this->load->view("layout/_footer");
 
   }


PHP Code:
abstract class FF_Model extends CI_Model
{
 
  public function getDbInstance($show_errors true) {
 
       $this->load->database();

 
       //Nasconde la pagina d'errore di MySQL che mi fa fallire Ajax
 
       $this->db->db_debug $show_errors;

 
       return $this->db;
 
   }

 
   public abstract function mapFromDb($result);
 
   public abstract function mapToDb($result);



application/controllers
PHP Code:
class Login extends FF_Controller
{
 
   public function index()
 
   {
 
       $this->LoadView("login/index");
 
   }

 
   public function dologin()
 
   {
 
       $user $this->input->post('username');
 
       $pwd $this->input->post('password');

 
       $this->load->model("user_model");
 
       $usr $this->user_model->get($user$pwd);

 
       $this->session->set_userdata(array('user' => $usr));
 
       redirect(base_url());
 
   }



application/config/autoload.php
PHP Code:
<?php
$autoload
['packages'] = array();
$autoload['libraries'] = array('session');
$autoload['drivers'] = array();
$autoload['helper'] = array('url');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array(); 

application/models
PHP Code:
class User_model extends FF_Model
{
 
   public function get($mail$pwd)
 
   {
 
       $db $this->getDbInstance();
 
       
        
//Login data retriving with pwd encoding: all written inline with querybuilder

 
       $res $this->mapFromDb($db->get()->result());
 
       if(count($res) == 1) return $res[0];
 
       else return false;
 
   }




Removing the autoload "session" entry all working.

Looking in System/libraries seems that session.php does not exists. Nevertheless, that file seems to be in the Session subdirectory (system/libraries/session/). But load_class(...) is not looking inside that folder:

PHP Code:
// Look for the class first in the local application/libraries folder
        // then in the native system/libraries folder
        
foreach (array(APPPATHBASEPATH) as $path)
        {
            if (
file_exists($path.$directory.'/'.$class.'.php'))
            {
                
$name 'CI_'.$class;

                if (
class_exists($nameFALSE) === FALSE)
                {
                    require_once(
$path.$directory.'/'.$class.'.php');
                }

                break;
            }
        } 


How can i set to work properly my session library?
PS: loading it manually from the controller method does not change the result. I still get the error. Logs are pretty clean. Only debug infos not related to sessions.
Reply
#2

(This post was last modified: 06-13-2017, 11:59 PM by Martin7483.)

A file in the Core could be incomplete and or corrupted. Download a fresh CodeIgniter package and overwrite the system directory with the freshly downloaded one.

EDIT

Are you using
PHP Code:
load_class("Session/Session""core"

for session loading or are you loading via

PHP Code:
$this->load->library("session"
Reply
#3

(06-13-2017, 11:50 PM)Martin7483 Wrote: A file in the Core could be incomplete and or corrupted. Download a fresh CodeIgniter package and overwrite the system directory with the freshly downloaded one.

EDIT

Are you using
PHP Code:
load_class("Session/Session""core"

for session loading or are you loading via

PHP Code:
$this->load->library("session"

Done yesterday, while i'm getting crazy with this problem. My "system" forlder is a fresh downloaded version (CI 3.1.4).
No such way to get the correct loading of the sessions....

About my loading:
Absolutely i'm not calling load_class.
Also, the loading of Session is not by the loader class in the controller. I use CI autoload (autoload.php)
PHP Code:
$autoload['libraries'] = array('session'); 


If i remove this, and i load session by "$this->load->library("session")" no change. Still getting the issue.
Reply
#4

Setup a clean install of CodeIgniter and autoload the session library.

I have multiple CI 3.x versions and none of them have this issue.
Reply
#5

It is not clear to me exactly what problem you are having.

The loader class will find Session.php even though it is in a subfolder.

You can use
PHP Code:
var_dump($this->session); 
any place you want to check that the session library is loaded. If not loaded you will get a PHP error.

If sessions are not functioning properly it might be a config settings problem. What setting do you have for sessions and cookies?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB