Fixing TestCookie see BT#8883

1.9.x
Julio Montoya 11 years ago
parent 6be3d16b79
commit 6f61e3c49a
  1. 8
      index.php
  2. 16
      main/inc/lib/main_api.lib.php

@ -5,9 +5,7 @@
* @package chamilo.main
*/
use \ChamiloSession as Session;
define('CHAMILO_HOMEPAGE', true);
$language_file = array('courses', 'index', 'userInfo');
@ -16,6 +14,9 @@ $language_file = array('courses', 'index', 'userInfo');
// Maybe we should change this into an api function? an example: CourseManager::unset();
$cidReset = true;
// Set cookie for check if client browser are cookies enabled
setcookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
require_once 'main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';
require_once 'main/chat/chat_functions.lib.php';
@ -42,9 +43,6 @@ $htmlHeadXtra[] ='
});
</script>';
//set cookie for check if client browser are cookies enabled
setcookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
$controller = new IndexManager($header_title);
//Actions

@ -3226,10 +3226,20 @@ function api_not_allowed($print_headers = false, $message = null)
$tpl->display_one_col_template();
exit;
}
$msg = null;
// Check if the cookies are enabled. If are enabled and if no course ID was included in the requested URL, then the user has either lost his session or is anonymous, so redirect to homepage
if( !isset($_COOKIE['TestCookie']) && empty($_COOKIE['TestCookie']) ) {
$msg = Display::return_message(get_lang('NoCookies').'<br /><br /><a href="'.$home_url.'">'.get_lang('BackTo').' '.get_lang('CampusHomepage').'</a><br />', 'error', false);
/* Check if the cookies are enabled. If are enabled and if no course Id was
included in the requested URL, then the user has either lost his session
or is anonymous, so redirect to homepage
*/
if (!isset($_COOKIE['TestCookie']) ||
isset($_COOKIE['TestCookie']) && empty($_COOKIE['TestCookie'])
) {
$msg = Display::return_message(
get_lang('NoCookies').'<br /><br /><a href="'.$home_url.'">'.
get_lang('BackTo').' '.get_lang('CampusHomepage').'</a><br />', 'error',
false
);
} else {
// The session is over and we were not in a course,
// or we try to get directly to a private course without being logged

Loading…
Cancel
Save