Codeigniter in PHPStorm - codeigniter

I need to know if any special configuration in the ide PhpStorm to use CodeIgniter . I'm having problems permission to access session variables and writing temporary files . The server is XAMPP local for IOS
Error from comment
A PHP Error was encountered Severity: Warning Message: Unknown: Failed
to write session data (files). Please verify that the current setting
of session.save_path is correct (/Applications/temp/) Filename:
Unknown Line Number: 0 Backtrace: A PHP Error was encountered
Severity: Warning Message: Unknown:
open(/Applications/temp//sess_acelvldc0c60ti1pj13fmil6t6, O_RDWR)
failed: Permission denied (13) Filename: Unknown Line Number: 0
Backtrace

When you use session files on codeigniter 3
Where ever you save your file example:
application
application > temp
Then on your config.php
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = APPPATH . 'temp/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
Make sure the sess_save_path has /at end.
Also make sure you have set temp folder permissions to chmod 0700 You need set permission for your var directory

Related

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

I am getting error not regularly but after time intervals:
Message:
unlink(/tmp/ci_session0189a7f1c86eb18fb70afcfedc2d5040e9c23146):
Operation not permitted
In config I tried:
$config['sess_save_path'] = sys_get_temp_dir();
Also tried:-
In config:
$config['sess_save_path'] = BASE_URL.'application/temp/';
also changed the permission of it (755 & 777)
Though not getting resolved..
Use FCPATH or APPPATH
Location application > temp
$config['sess_save_path'] = APPPATH . 'temp/';
OR
$config['sess_save_path'] = FCPATH . 'application/temp/';
Folder permission for sessions 0700
EXT: The PHP file extension
FCPATH: Path to the front controller (this file) (root of CI)
SELF: The name of THIS file (index.php)
BASEPATH: Path to the system folder
APPPATH: The path to the "application" folder

codeigniter session loading error: No such file or directory

I am following this tutorial:
however when I access to
http://localhost/index.php/user_authentication/
I got this get warning and cannot get the code running:
Warning: include(C:\xampp\htdocs\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\system\core\Exceptions.php on line 269
Warning: include(): Failed opening 'C:\xampp\htdocs\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\system\core\Exceptions.php on line 269
Warning: include(C:\xampp\htdocs\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\system\core\Exceptions.php on line 269
Warning: include(): Failed opening 'C:\xampp\htdocs\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\system\core\Exceptions.php on line 269
When I remove the $this->load->library('session');
the warnings are gone so I am pretty sure I got the error in loading the session library.
I have read that the issue is fixed by changing $config['sess_save_path'] = sys_get_temp_dir();
but i still get the warning.
I even tried adding this code to my controller:
mkdir("/thisisthedirectory", 0700);
then changed my $config['sess_save_path'] = "/thisisthedirectory"; but it doesn't work
nor $config['sess_save_path'] = "C:\thisisthedirectory";
Can anybody tell me how to fix this problem?
Make sure you have set your session save path something like
$config['sess_save_path'] = APPPATH . 'cache/';
Folder Permissions 0700
Config.php
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = APPPATH . 'cache/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;
Note: Make sure you have followed the Codeigniter Style Guide For File Naming and Class Naming
While you are working with .env file and your sessionSavePath will not absolute it will show error like this
set your sessionSavePath as absolute path as below
app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
app.sessionCookieName = 'ci_session'
app.sessionSavePath = '/home/user/public_html/project/public/NULL'
app.sessionMatchIP = false
app.sessionTimeToUpdate = 300
app.sessionRegenerateDestroy = false
It will fix your problem
Thank you
you may try to load parent constructor like this
parent::__construct();
$this->load->library('session');
I hope it solves the problem

Codeigniter Sessions Do Not Work On Live Server

When open codeigniter project localhost they work properly and open in server then error of invalid path
A PHP Error was encountered
Severity: Warning
Message: mkdir(): Invalid path
Filename: drivers/Session_files_driver.php
Line Number: 117
Backtrace:
File: /Library/Server/Web/Data/Sites/garden_worx/index.php Line: 292
Function: require_once
Error 2
An uncaught Exception was encountered
Type: Exception
Message: Session: Configured save path '' is not a directory, doesn't
exist or cannot be created.
Filename:
/Library/Server/Web/Data/Sites/garden_worx/system/libraries/Session/drivers/Session_files_driver.php
Line Number: 119
Backtrace:
File: /Library/Server/Web/Data/Sites/garden_worx/index.php Line: 292
Function: require_once
Error 3
A PHP Error was encountered
Severity: Warning
Message: fopen(6d898f163e36616cef220426dad109225a66f74a): failed to
open stream: Permission denied
Filename: drivers/Session_files_driver.php
Line Number: 156
Backtrace:
This will be really helpful to you, it was save my day too :)
in your config.php
$config['sess_save_path'] = sys_get_temp_dir();
Similar Question
session error in codeigniter?
In codeigniter 3 versions you can use files or database if files, make sure you have created folder where you would like your session path set and chmod 700
I use cache folder to store files sessions
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 1440;
$config['sess_save_path'] = FCPATH . 'application/cache/sessions/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;
Auto load session in application > config > autoload
$autoload['libraries'] = array('session');
Note: Make sure all file names and class names of controllers,
models, libraries have first letter upper case example filename Welcome.php and class Welcome extends CI_Controller {}.
Codeigniter doc's 2 and 3 http://www.codeigniter.com/docs
Codeigniter 3 session http://www.codeigniter.com/user_guide/libraries/sessions.html
Codeigniter 2 session: http://www.codeigniter.com/userguide2/libraries/sessions.html
You also may need to have a encryption_key on config.php
$config['encryption_key'] = 'pXeQY2733rR560MrwJy40OL4WaSGmr5A';
http://randomkeygen.com/
Simply change this in your, application -> config -> config.php
$config['sess_save_path'] = NULL;
To
$config['sess_save_path'] = FCPATH.'ci_sessions';
It will create a Directory in your Root.
Hopefully your problem will solve ...
Thanks
This worked for me
$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'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
you can also put
output_buffering = On
in your php.ini file on the root
Change 'NULL' to either '/tmp' or your servers temp folder path
The line should now read:
$config['sess_save_path'] = '/tmp';
adding 'session' in autoload.php file solved my problem
$autoload['libraries'] = array('form_validation','session');
This work for me
$config['sess_save_path'] = sys_get_temp_dir();

Codeigniter error log not working

I want to log my details for log my application event. So i have changed config.php as follows.
$config['log_threshold'] = 4;
$config['log_path'] = 'application/logs/main';
$config['log_date_format'] = 'Y-m-d H:i:s';
I use it in my controller as like this.
log_message('error', 'Some variable did not contain a value.');
I grant write permission to main file. bt it is not working. What is the issue.
log_path is meant to be a folder not a file. If main is a folder then you should add a trailing /

ftp transfer using codeigniter version 2

$this->load->library('ftp');
$config['hostname'] = 'text.com';
$config['username'] = 'test';
$config['password'] = '12345678';
$config['port'] = 21;
$config['passive'] = FALSE;
$config['debug'] = TRUE;
$conn = $this->ftp->connect($config);
if($conn){
$this->ftp->upload('/ftp1_uploads/images/test.zip','/ftp2_uploads/images/test.zip');
}
I want to transfer from ftp1 to ftp2 not the same domain.
Return error below using codeigniter version 2
An Error Was Encountered
Unable to locate the source file. Please check your path.
I already try rename the file using the same path its works. but when I transfer from ftp1 to ftp2 different domain it will not work.
You can't transfer files from ftp1 to ftp2 without using interim location, your algorithm is: download from ftp1 to local, upload from local to ftp2

Resources