Failed to write session data Error in codeigniter

Sometimes we occured with the below issue at the end of the page

A PHP Error was encountered
Severity: Warning

Message: touch(): Unable to create file 2;/home/sessions/intranet_sessionn6cti57kfphajiq1husmhdksjl0ju53q because No such file or directory

Filename: drivers/Session_files_driver.php

Line Number: 248

Backtrace:

A PHP Error was encountered
Severity: Warning

Message: Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (2;/home/sessions)

Filename: Unknown

Line Number: 0

Backtrace:

For that we need to set the config variable like the below one:

$config[‘sess_save_path’] = sys_get_temp_dir();