security_check_session_saved_group_key

 
          security_check_session_saved_group_key(string $session_group_key, array $allowed_group_array)  
This is one of the session verification methods for private reports! It configures your report to check both the existence of a given session key (such as the active user's group or group id) and its value which should be an element in the "$allowed_group_array" parameter. This method should be used if your project supports user groups, and you choose to allow only certain groups to access your report. So, in your login page, and after validating the login credentials of each user, you store the active user's group or group id in the session, and you want Smart Report Engine to check this key and allow only the users of the allowed group(s) to be able to access your private report.
Like other session verification methods of Smart Report Engine, if this session validation fails, the user should be redirected to the login page that you passed to the "security_init" method.
# This method is exclusive to the commercial edition and is not supported in the community edition .

# Parameters

Parameter Description
$session_group_keyA session key in your project that references the active user group or group id. You want the engine to check for the existence of this key in the session before allowing any access to your private report.
$allowed_group_arrayan array of names or IDs of the groups that are allowed to access your report. For example array(3, 5) or array("sales","admins")

# Returns

This method returns the calling object, so it can be chained with other methods in the ‘ReportOptions’ class

# Code Example

 
           $report = new ReportOptions(SRE_PRIVATE_REPORT);
$report->select_tables(array("items"))
       ->select_all_fields()
       ->security_init("some_login_page_url","some_logout_page_url","project1")
       ->security_check_session_saved_user_key("user_id")
       ->security_check_session_saved_group_key("group", array("sales", "admins"));
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
  echo "Your report URL:" . $report_path;
}