CodeIgniter Session Error - Unlink Operation not P

2019-03-18 04:53发布

问题:

I'm trying to debug this CodeIgniter issue I am having with my application. I cannot figure it out so I was wondering if anyone else has come across this and could shed some light on it?

This occurs randomly when a user is logged in. The user could be browsing and all of a sudden this error pops up. Refresh the browser and it's gone.

CodeIgniter 3

Thanks!

A PHP Error was encountered

Severity: Warning

Message: unlink(/tmp/ci_session0189a7f1c86eb18fb70afcfedc2d5040e9c23146): Operation not permitted

Filename: drivers/Session_files_driver.php

Line Number: 346

Backtrace:

File: /home/*****/public_html/application/controllers/User.php
Line: 5
Function: __construct

File: /home/*****/public_html/index.php
Line: 292
Function: require_once

回答1:

After doing some more research I found the issue and the answer.

In the config.php file you MUST set sess_save_path to a valid path. It was initially set to NULL. I have mine set to:

 $config['sess_save_path'] = BASEPATH . 'cache/';

Now the sessions are being saved in this folder and can be unlinked when needed to.



回答2:

I change on "application/config/config.php" :

$config['sess_save_path'] = NULL;

To:

 $config['sess_save_path'] = APPPATH . 'cache'; (or another folder)

location folder "cache" is "application/cache".



回答3:

change application > config > config.php

$config['sess_save_path'] =  BASEPATH . 'cache/';