Welcome Guest, Not a member yet? Register   Sign In
Problem with session files
#1

Hello everybody,

we develop with CI from many years but we have a weird thing that happen with our last project.

We use CI 3.1.3 on virtualized server with VMware. The "sess_driver" parameter is set to "files".

Sometimes we get this error: 

Severity: Warning --> filesize(): stat failed for /webroot/temp/webcrm/evolutionweb_ikbbigqenm63k241vhle4nhh96oshui9 /webroot/engine/system/libraries/Session/drivers/Session_files_driver.php 208

This file is not updated in the latest CI versions.

Looking at the code we think it's something going wrong between row 170 (where file presence is checked) and row 208 (where file is read).

Now we are tring to switch to "tmpfs" to have more fast access to filesystem. No idea if this can fix it.

Any other suggestion or fixes?
Reply
#2

How big is the file?
Reply
#3

That path does not look like the complete path. The session file path must be complete and absolute - like from the /root/to/the/eventual/folder/for/session_files/

I'm guessing yours should look more like /var/www/webroot/temp/webcrm/

What's assigned to $config['sess_save_path'] ?
Reply
#4

(11-22-2017, 12:17 PM)PaulD Wrote: How big is the file?

Hello PaulD,

I don't know what it's the size of the "problemating" file because it was no longer present.


Checking on production server the biggest file is 30825 bytes.

There are many other files of 20-25 KB.

Do you think it depends on that?
Reply
#5

(11-22-2017, 09:01 PM)dave friend Wrote: That path does not look like the complete path. The session file path must be complete and absolute - like from the /root/to/the/eventual/folder/for/session_files/

I'm guessing yours should look more like /var/www/webroot/temp/webcrm/

What's assigned to $config['sess_save_path'] ?

Hello dave,


thank you for your reply. The path are correct and already absloute. 

These are our settings:

  $config['sess_driver'] = 'files';
  $config['sess_cookie_name'] = 'crm_';
  $config['sess_expiration'] = 0;
  $config['sess_save_path'] = '/webroot/temp/webcrm/';
  $config['sess_match_ip'] = FALSE;
  $config['sess_time_to_update'] = 60 * 30;
  $config['sess_regenerate_destroy'] = FALSE;
Reply
#6

Hi All,

May I know if you already know how to fix this issue?

Thanks
Reply
#7

I create a folder under the application folder called writable.

./application/writable

then set the sessions up like below works fine for me.

PHP Code:
$config['sess_driver'             'files';
$config['sess_cookie_name'        'pcfx_session_'// change pcfx to you name
$config['sess_expiration'         7200;
$config['sess_save_path'          APPPATH.'writable'// create a folder under ./application/writable
$config['sess_match_ip'           FALSE;
$config['sess_time_to_update'     300;
$config['sess_regenerate_destroy' FALSE
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(11-23-2017, 01:09 AM)raffaele.bennoli Wrote: thank you for your reply. The path are correct and already absloute. 

These are our settings:

  $config['sess_driver'] = 'files';
  $config['sess_cookie_name'] = 'crm_';
  $config['sess_expiration'] = 0;
  $config['sess_save_path'] = '/webroot/temp/webcrm/';
  $config['sess_match_ip'] = FALSE;
  $config['sess_time_to_update'] = 60 * 30;
  $config['sess_regenerate_destroy'] = FALSE;

I may be wrong because I have no knowledge of your file structure, but 'sess_save_path' does not look complete to me. It has to be the complete path from the root of the drive. In a typical Linux setup it would look more like this.

PHP Code:
$config['sess_save_path'] = '/var/www/webroot/temp/webcrm/'
Reply
#9

php filesize() function is Returns the size of the file in bytes, or false (and generates an error of level E_WARNING) in case of an error.

Ref: https://www.php.net/manual/en/function.filesize.php

# Reason of error: I found two main reason of this error:
1. File doesn’t exist
2. File exist but file size is larger than 2GB which that’s why filesize() function can’t read that file.

I found a problem in code codeigniter session driver source code “Session_files_driver.php”.There is no file_exists () Checks whether a file or directory exists on the directory.
Please have a look on the system/libraries/Session/drivers/Session_files_driver.php line no 208

for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length;

I think the there should have checking if the file exist before try to read the file.

# Solution:
1. Set absolute path on session file

$config['sess_driver'] = 'files';
//$config['sess_save_path'] = NULL;
$config['sess_save_path'] = '/var/lib/php/sessfiles/';

2. Correct the session driver source code:

if (file_exists($this->_file_path.$session_id)) {
for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += self:Confusedtrlen($buffer))
{
if (($buffer = fread($this->_file_handle, $length - $read)) === FALSE)
{
break;
}

$session_data .= $buffer;
}
}


Hope this will help you to solve this problem.
Thank you
Every Problem Must have a Solution Big Grin
Reply
#10

(10-21-2018, 02:57 PM)clover Wrote: Hi All,

May I know if you already know how to fix this issue?

Thanks

following
Reply




Theme © iAndrew 2016 - Forum software by © MyBB