CodeIgniter Forums
Extending the session library - works on localhost but not on live server. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Extending the session library - works on localhost but not on live server. (/showthread.php?tid=47840)



Extending the session library - works on localhost but not on live server. - El Forum - 12-24-2011

[eluser]Unknown[/eluser]
Hi all,

I just have a very simple extension to CI_Session.
The custom library is called MY_session and is stored in application/libraries.

MY_session.php:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_session extends CI_session
{
function __construct()
{
  parent::__construct();
  session_start();
}

function is_logged_in()
{
  if(!isset($_SESSION['email']))
  {
   redirect('landing/logout');
  }
}

function logout()
{
  session_destroy();
  redirect('landing');
}

}

Nothing fancy.

I then access this in a controller called "home" as such:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller
{
function index()
{
  $this->session->is_logged_in();

//there is more in the controller but it's immaterial.
}

On my localhost this works fine. I try to access the "home" controller while logged out, and it redirects me to the logout function.

But, when I copied it word for word over to my live server it spits out this error:
Quote:Fatal error: Call to undefined method CI_Session::is_logged_in() in /home/rblake/public_html/application/controllers/home.php on line 9
It gives me that error regardless of whether $_SESSION['email'] is set.

My local dev is a WAMP setup.
My live server is LAMP.
Might there be something small in the details?

Many thanks for any help, and Merry Christmas!
Rob.