CodeIgniter with Zebra Session

Install

https://github.com/stefangabos/Zebra_Session

composer require stefangabos/zebra_session

index.php

Do not use session_start();

		case 'development':
			error_reporting(E_ALL);
			ini_set('display_errors',1);
		    ini_set('display_startup_errors',1);
		    ini_set('log_errors',1);

		    $link = mysqli_connect($_ENV['DB_HOST'], $_ENV['DB_USERNAME'], $_ENV['DB_PASSWORD'], $_ENV['DB_DATABASE']);
		    $session = new Zebra_Session($link, 'sEcUr1tY_c0dE', 3600);
		    $GLOBALS['session'] = $session;
			break;

Note: Put $session in $GLOBALS is very important or this variable wont’ be accessible in controllers and data in session will be lost after redirection and won’t be saved in database.

Note:

  1. If session doesn’t work after redirection, try clear all data in table “session_data”