tims-todo/application/hooks/pre-controller.php

32 lines
558 B
PHP
Raw Normal View History

2014-08-08 15:41:59 -04:00
<?php
/**
* Check Session
*
* Checks that the current user has a valid session, and if not, redirects
* to the login page.
* @return null
*/
function check_session()
{
2016-12-29 13:56:30 -05:00
$CI = get_instance();
2014-08-08 15:41:59 -04:00
if($CI->session->userdata('uid') == FALSE)
{
$referer = $CI->uri->uri_string();
$white_list = [
'login',
'login/register',
'register',
'reminder/check_reminder',
];
if ( ! in_array($referer, $white_list))
{
//Redirect to login
$CI->session->set_userdata('login_referer', $referer);
$CI->todo->redirect_303('login');
}
}
}