We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
config/config.php
$config['enable_hooks'] = TRUE;
config/hooks.php
$hook['post_controller_constructor'][] = array( "class" => "Check_session", "function" => "validate", "filename" => "Check_session.php", "filepath" => "hooks" );;
hooks/Check_session.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Check_session { public function __construct() { } public function __get($property) { if ( ! property_exists(get_instance(), $property)) { show_error('property: ' . strong($property) . ' not exist.'); } return get_instance()->$property; } public function validate() { if (in_array($this->router->class, array("login")))//login is a sample login controller { return; } if(!$this->session->has_userdata('user_id')) { //redirect in login } } }