public function __construct() { onapp_debug(__METHOD__); global $_SCREEN_IDS, $_ALIASES; $route = onapp_get_arg('route'); onapp_debug('route =>' . $route); if (onapp_is_auth() && $_SCREEN_IDS[$route]['alias'] == 'login') { onapp_debug('Redirecting :' . ONAPP_BASE_URL . '/' . $_ALIASES[ONAPP_DEFAULT_ALIAS]); onapp_redirect(ONAPP_BASE_URL . '/' . $_ALIASES[ONAPP_DEFAULT_ALIAS]); } elseif (!onapp_is_auth() && $_SCREEN_IDS[$route]['alias'] != 'login') { $_SESSION['redirect'] = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; onapp_debug('Setting after login redirect url => ' . $_SESSION['redirect']); onapp_debug('Redirecting :' . ONAPP_BASE_URL . '/' . $_ALIASES['login']); onapp_redirect(ONAPP_BASE_URL . '/' . $_ALIASES['login']); } }
/** * Handles sessions. * * @param string $time session lifetime * * @param string $ses session name * * @return void * */ function onapp_startSession($ses = 'MYSES') { onapp_debug(__METHOD__); if (!onapp_is_auth()) { $time = ONAPP_SESSION_LIFETIME; session_set_cookie_params($time); session_name($ses); session_start(); onapp_debug('Start SESSION'); // rotates error log files onapp_rotate_error_log(); // rotates debug log file onapp_rotate_debug_log(); // Reset the expiration time upon page load if (isset($_COOKIE[$ses])) { setcookie($ses, $_COOKIE[$ses], time() + $time, "/"); } } }