[未解决]CodeIgniter调用session出错


A PHP Error was encountered
Severity: Warning
Message: mkdir(): Invalid path
Filename: drivers/Session_files_driver.php
Line Number: 117
Backtrace:
File: /Users/Elsa/Sites/application/controllers/Login.php
Line: 22
Function: __construct
File: /Users/Elsa/Sites/index.php
Line: 292
Function: require_once
An uncaught Exception was encountered
Type: Exception
Message: Session: Configured save path '' is not a directory, doesn't exist or cannot be created.
Filename: /Users/Elsa/Sites/system/libraries/Session/drivers/Session_files_driver.php
Line Number: 119
Backtrace:
File: /Users/Elsa/Sites/application/controllers/Login.php
Line: 22
Function: __construct
File: /Users/Elsa/Sites/index.php
Line: 292
Function: require_once

在使用ci做项目的时候,发现了以上两条错误信息。
查找了一下网上的资料:
http://www.zhangty.cn/archives/53
http://stackoverflow.com/questions/29431910/codeigniter-cannot-load-libraries
说是在config.php里面:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

因为这一条

$config['sess_save_path'] = NULL;

的session储存的地址被定义为NULL。正确的做法应该是给他写一个存储的路径。建议是用tmp文档,会清空暂存的session。
然而我新建了一个folder名叫session_repository,然后把我的路径指定为(我的操作系统是mac):

$config['sess_save_path'] = '/Users/xxxx/Sites/session_repository';

于是这个问题就解决了,不过跳转到下一个问题:
Unable to locate the specified class: Session.php

然而我按照网上的资料,把autoload.php里面的内容改成如下也无法解决:

$autoload['drivers'] = array('session');

未完待续……

智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告