CodeIgniter Forums
$autoload['libraries'] = array('session'); error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: $autoload['libraries'] = array('session'); error (/showthread.php?tid=68820)



$autoload['libraries'] = array('session'); error - HEKuiper - 08-30-2017

Hello,



Running localhost Apache with PHP Version 7.1.8 OS X Yosemite, I copied CodeIgniter into the webserver/Documents folder.



I tested it in Chrome and Safari, it works.  I started to configure it and after doing this: $autoload['libraries'] = array('session'); it broke with the following errors:


A PHP Error was encountered
Severity: Warning
Message: mkdir(): Invalid path
Filename: drivers/Session_files_driver.php
Line Number: 136
Backtrace:
File: /Library/WebServer/Documents/katana/index.php
Line: 315
Function: require_once



( ! ) Warning: Uncaught Exception: Session: Configured save path '' is not a directory, doesn't exist or cannot be created. in /Library/WebServer/Documents/katana/katana/libraries/Session/drivers/Session_files_driver.php:138 Stack trace: #0 [internal function]: CI_Session_files_driver->open('', 'ci_session') #1 /Library/WebServer/Documents/katana/katana/libraries/Session/Session.php(143): session_start() #2 /Library/WebServer/Documents/katana/katana/core/Loader.php(1281): CI_Session->__construct() #3 /Library/WebServer/Documents/katana/katana/core/Loader.php(1174): CI_Loader->_ci_init_library('Session', 'CI_', NULL, 'session') #4 /Library/WebServer/Documents/katana/katana/core/Loader.php(1037): CI_Loader->_ci_load_stock_library('Session', 'Session/', NULL, NULL) #5 /Library/WebServer/Documents/katana/katana/core/Loader.php(1082): CI_Loader->_ci_load_library('Session', NULL, NULL) #6 /Library/WebServer/Documents/katana/katana/core/Loader.php(218): CI_Loader->_ci_load_library('Session', NULL, NULL) #7 /Library/WebServer/Docum in /Library/WebServer/Documents/katana/katana/libraries/Session/drivers/Session_files_driver.php on line 138

Now what??


Thanks.


RE: $autoload['libraries'] = array('session'); error - Narf - 08-30-2017

The error message literally tells you what the problem is.


RE: $autoload['libraries'] = array('session'); error - HEKuiper - 08-30-2017

It's a freshly unzipped setup and I have no idea where to the invalid path is...

Please enlighten me.


RE: $autoload['libraries'] = array('session'); error - HEKuiper - 08-30-2017

(08-30-2017, 09:47 AM)Narf Wrote: The error message literally tells you what the problem is.

From my config file:

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

I modified it as per the instructions in the user guide.
I also created the database table as specified.

Thanks.


RE: $autoload['libraries'] = array('session'); error - ciadmin - 08-30-2017

Your session configuration shows that you are using the *files* driver, but you have not set the *session_save_path* to a valid folder for the session driver to use.

https://www.codeigniter.com/user_guide/libraries/sessions.html#session-preferences
https://www.codeigniter.com/user_guide/libraries/sessions.html#files-driver

If you think you have configured it to use the database driver, the error message quite explicitly tells yoiu it is trying to use the files driver.


RE: $autoload['libraries'] = array('session'); error - HEKuiper - 08-30-2017

(08-30-2017, 11:12 AM)ciadmin Wrote: Your session configuration shows that you are using the *files* driver, but you have not set the *session_save_path* to a valid folder for the session driver to use.

https://www.codeigniter.com/user_guide/libraries/sessions.html#session-preferences
https://www.codeigniter.com/user_guide/libraries/sessions.html#files-driver

If you think you have configured it to use the database driver, the error message quite explicitly tells yoiu it is trying to use the files driver.

Please see the above answer - I did what the instructions said and I also created a "sessions" folder in the applications folder.

The attached image is a screenshot of the MySQL console in a terminal window.

I followed the instructions explicitly and still the errors remain, but only when I autoload the sessions library.

Thanks.


RE: $autoload['libraries'] = array('session'); error - ciadmin - 08-30-2017

Is the error message the same as from your original post? or are you getting a different error message now?


RE: $autoload['libraries'] = array('session'); error - HEKuiper - 08-30-2017

(08-30-2017, 12:26 PM)ciadmin Wrote: Is the error message the same as from your original post? or are you getting a different error message now?

How weird is that...

I just re-loaded the session library and this time it worked, I even have 1 record in the database plus 2 cookies...

Thanks.

PS further testing points to browser cache...