CodeIgniter Forums
Migrating from 3 to 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Migrating from 3 to 4 (/showthread.php?tid=88888)



Migrating from 3 to 4 - pippuccio76 - 11-28-2023

HI , i want migrate a project from 3 to 4 slowly .
In two subfolder of same site a put a copy of ci3 and a copy of ci4 , i can send data via post or get correctly (from two version) . The only problem is use the same session data .
 If i use the same db's table for session is it possible ?


RE: Migrating from 3 to 4 - kenjis - 11-28-2023

FileHandler does not work if both use the same folder?

timestamp type is different. It does not work.
The table schemes seem to be the same. So it seems to work.
Why don't you try?
https://codeigniter4.github.io/CodeIgniter4/libraries/sessions.html#creating-database-table
https://codeigniter.com/userguide3/libraries/sessions.html#database-driver


RE: Migrating from 3 to 4 - pippuccio76 - 12-03-2023

(11-28-2023, 03:04 PM)kenjis Wrote: FileHandler does not work if both use the same folder?

timestamp type is different. It does not work.
The table schemes seem to be the same. So it seems to work.
Why don't you try?
https://codeigniter4.github.io/CodeIgniter4/libraries/sessions.html#creating-database-table
https://codeigniter.com/userguide3/libraries/sessions.html#database-driver


Try to use file :

ci3 : 

Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_samesite'] = 'Lax';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = APPPATH.'../../session_common';

ci4 (.env) :

Code:
  session.driver = 'CodeIgniter\Session\Handlers\FileHandler'
  session.cookieName = 'ci_session'
  session.expiration = 7200
  session.savePath = APPPATH.'../../session_common'


this is the error :

Code:
ErrorException
mkdir(): File exists


SYSTEMPATH/Session/Handlers/FileHandler.php at line 96

89      * @param string $path The path where to store/retrieve the session
90      * @param string $name The session name
91      *
92      * @throws SessionException
93      */
94    public function open($path, $name): bool
95    {
96        if (! is_dir($path) && ! mkdir($path, 0700, true)) {
97            throw SessionException::forInvalidSavePath($this->savePath);
98        }
99
100        if (! is_writable($path)) {
101            throw SessionException::forWriteProtectedSavePath($this->savePath);
102        }