user_guide_src/source/installation/upgrade_sessions.rst
Upgrade Sessions ################
.. contents:: :local: :depth: 2
Session Library Documentation CodeIgniter 3.x <http://codeigniter.com/userguide3/libraries/sessions.html>_Session Library Documentation CodeIgniter 4.x </libraries/sessions>Wherever you use the Session Library replace $this->load->library('session'); with $session = session();.
From that on you have to replace every line starting with $this->session with $session followed by the new method name.
$session->item or $session->get('item') instead of the CI3 syntax $this->session->name.$session->set($array); instead of $this->session->set_userdata($array);.unset($_SESSION['some_name']); or $session->remove('some_name'); instead of $this->session->unset_userdata('some_name');.$session->markAsFlashdata('item'); instead of ``$this->session->mark_as_flash('item');```If you use Database Driver, you need to recreate the session table. See :ref:sessions-databasehandler-driver.
.. literalinclude:: upgrade_sessions/ci3sample/001.php
.. literalinclude:: upgrade_sessions/001.php