Codeigniter Call to a member function set_userdata() on a non-object

偶尔善良 提交于 2019-12-06 06:06:40

You can't use $this inside a helper as a helper file is just a collection of functions (no class there). To use the functionality provided by $this of controller, you'll have to do:

$ci = & get_instance();
$ci->session->set_userdata("admin", $user[0]["admin"]);

$CI =& get_instance();

$CI->load->library('session');

Are you loading the session librairy in the constructor and after the parent::__construct() instruction?

Luigi Usai

You are using the default configuration of Codeigniter. The problem is: NO DATABASE CONFIGURATION DONE! You must enter here: \YOUR_APPLICATION_NAME\application\config\database.php

and you must open this file with a text editor.

Set the following variables and you are done:

$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "127.0.0.1";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "NameOfYourDatabase";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!