Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter中的会话错误?_Php_Codeigniter_Session - Fatal编程技术网

Php codeigniter中的会话错误?

Php codeigniter中的会话错误?,php,codeigniter,session,Php,Codeigniter,Session,当我想在codeigniter 3中设置会话数据时,它会显示如下错误: A PHP Error was encountered Severity: Warning Message: mkdir(): Invalid path Filename: drivers/Session_files_driver.php Line Number: 117 Backtrace: File: C:\xampp\htdocs\ci-test\application\controllers\login.

当我想在codeigniter 3中设置会话数据时,它会显示如下错误:

A PHP Error was encountered

Severity: Warning

Message: mkdir(): Invalid path

Filename: drivers/Session_files_driver.php

Line Number: 117

Backtrace:

File: C:\xampp\htdocs\ci-test\application\controllers\login.php
Line: 7
Function: __construct

File: C:\xampp\htdocs\ci-test\index.php
Line: 292
Function: require_once
下面是要在其中设置会话数据的代码

$sess_array = array(
         'id' => 1,
         'username' => 'bikramkc.kc@gmail.com'
       );
$this->session->set_userdata($sess_array);

遇到错误的原因是您没有
$config['sess\u save\u path']

转到您的
config.php
并设置

$config['sess_save_path'] = NULL;

在config.php中试试这个
$config['sess\u save\u path']=NULL

共享帮助我的解决方案,请尝试将配置变量设置为:

$config['sess_save_path'] = sys_get_temp_dir();

当我们在CodeIgniter中使用基于目录的会话方法时,会出现此错误。如果我们使用基于数据库的会话方法,错误就会消失。使用下面的代码-

更改应用程序->配置->config.php并设置

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
&运行SQL查询

CREATE TABLE IF NOT EXISTS `ci_sessions` (
        `id` varchar(40) NOT NULL,
        `ip_address` varchar(45) NOT NULL,
        `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
        `data` blob NOT NULL,
        PRIMARY KEY (id),
        KEY `ci_sessions_timestamp` (`timestamp`)
);

在config.php中
sess\u save\u path
应该是
sys\u get\u temp\u dir()然后它将解决
mkdir()的错误:无效路径

  • 在配置文件中为
    $config['sess\u save\u path']
    使用绝对路径
  • 将它指向您的可写临时目录
  • 确保该目录位于apache或nginx配置中允许的目录下

  • 如果
    $config['sess\u save\u path']
    sys\u get\u temp\u dir()
    ,则会话数据将存储在系统文件夹中

    如果您使用以下config.php将数据库表作为ci_会话:

    $config['sess_driver']='database';
    $config['sess_cookie_name']='ci_session'


    数据将存储在数据库中。在这种情况下,您可以
    $config['sess\u save\u path']=NULL

    这可能是由于PHP和codeIgniter版本。 对我来说,PHP7.1.25和CI 3.0.4不起作用。您可以使用会话_id()进行检查。会话已刷新。
    对于CI 3.1.2,它可以正常工作

    我有一个类似的案例,我在godaddy中有一个多主机,首先我更正了.htacces文件

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase / 
    
        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /index.php?/$1 [L]
    
        RewriteCond %{REQUEST_URI} ^application.*
        RewriteRule ^(.*)$ /index.php?/$1 [L]
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c> 
        ErrorDocument 404 /index.php
    </IfModule>
    

    1.打开application/config文件夹上的config.php

    2.一直向下浏览到
    $config['sess\u save\u path']=NULL


    3.将
    NULL
    值更改为
    BASEPATH'sessions'

    您需要在控制器
    $this->load->library('session')中检查此加载更新完整代码第117行是什么?我猜第117行是指CI附带的php会话驱动程序。我在install.thanx上看到了类似的东西,但是已经有$config['sess\u save\u path']=NULL;在config.phpokk中设置尝试在路径上设置它,如
    $config['sess\u save\u path']=BASEPATHyourfoldername/cache/'Ion Auth应在尝试执行操作和崩溃所有应用程序之前验证此路径。在默认设置中,此变量设置为NULL,只需将其更改为sys_get_temp_dir();我认为这不管用,但确实管用。你怎么知道的?它确实给出了错误的信息。当我们使用基于目录的会话方法时,会出现此错误。使用基于db的会话方法错误将消失。请用英语填写您的答案,因为它会很好地工作
    
    $config['sess_driver'] = 'files';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = sys_get_temp_dir();
    $config['sess_match_ip'] = FALSE;
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = FALSE;