Bitrix Site Manager

CSession::GetList

CDBResult
CSession::GetList(
 string &by = "s_id",
 string &order = "desc",
 array filter = array(),
 bool &is_filtered
)

The method GetList returns a list of sessions.

Parameters

Parameter Description
by Sorting field; possible values:
  • s_id - the session ID;
  • s_last_site_id - the ID of the last hit site;
  • s_first_site_id - the ID of the first hit site;
  • s_date_first - date and time the first hit occurred;
  • s_date_last - date and time the last hit occurred;
  • s_user_id - the ID of a user under which the visitor was last authorised;
  • s_guest_id - the visitor ID;
  • s_ip - the visitor IP address during the last hit;
  • s_hits - number of hits occurred during this session;
  • s_events - number of events occurred during this session;
  • s_adv_id - the ID of an advertising campaign that led the visitor to the site;
  • s_country_id - the visitor country ID;
  • s_url_last - the first page (hit) of the session;
  • s_url_to - the last page (hit) of the session.
order Sort order; the following values are possible:
  • asc - ascending;
  • desc - descending.
filter Array used to filter the resulting list. The following keys can be used in the array:
  • ID* - the session ID;
  • ID_EXACT_MATCH - if "N", entry in the ID is sufficient (loose match);
  • GUEST_ID* - the visitor ID;
  • GUEST_ID_EXACT_MATCH - if "N", entry in the GUEST_ID is sufficient (loose match);
  • NEW_GUEST - flag: new visitor (Y|N);
  • USER_ID* - the ID of a user under which the visitor was last authorised;
  • USER_ID_EXACT_MATCH - if "N", entry in the USER_ID is sufficient (loose match);
  • USER_AUTH - flag: whether the visitor was authorised during this session (Y|N);
  • USER* - ID, first and last names of a user under which the visitor was last authorised;
  • USER_EXACT_MATCH - if "Y", the USER must match exactly (strict match);
  • REGISTERED - flag: whether the visitor was authorised during this session or before (Y|N);
  • FAVORITES - flag: the site was added to Favorites (Y|N);
  • EVENTS1 - minimum number of events generated during the session;
  • EVENTS2 - maximum number of events generated during the session;
  • HITS1 - minimum number of hits generated during the session;
  • HITS2 - maximum number of hits generated during the session;
  • ADV - flag: whether the visitor came under an advertising campaign (Y|N);
  • ADV_ID* - the advertising campaign ID;
  • ADV_ID_EXACT_MATCH - if "N", entry in the ID is sufficient (loose match);
  • ADV_BACK - flag: direct hit (N) or return (Y) under an advertising campaign;
  • REFERER1* - the referer1 identifier of an advertising campaign;
  • REFERER1_EXACT_MATCH - if "Y", the REFERER1 must match exactly (strict match);
  • REFERER2* - the referer2 identifier of an advertising campaign;
  • REFERER2_EXACT_MATCH - if "Y", the REFERER2 must match exactly (strict match);
  • REFERER3* - the referer3 auxiliary parameter of an advertising campaign;
  • REFERER3_EXACT_MATCH - if "Y", the REFERER3 must match exactly (strict match);
  • STOP - flag: whether the visitor was put in the stop list (Y|N);
  • STOP_LIST_ID* - the ID of the stop list record for the visitor (if applicable);
  • STOP_LIST_ID_EXACT_MATCH - if "N", entry in the STOP_LIST_ID is sufficient (loose match);
  • COUNTRY_ID* - the visitor country ID;
  • COUNTRY_ID_EXACT_MATCH - if "N", entry in the COUNTRY_ID is sufficient (loose match);
  • COUNTRY* - name of the visitor country;
  • COUNTRY_EXACT_MATCH - if "Y", the COUNTRY must match exactly (strict match);
  • IP* - the visitor IP address during the last hit;
  • IP_EXACT_MATCH - if "Y", the IP must match exactly (strict match);
  • USER_AGENT* - the visitor UserAgent;
  • USER_AGENT_EXACT_MATCH - if "Y", the USER_AGENT must match exactly (strict match);
  • DATE_START_1 - first value of the first hit generation time range (time from which the first hit could be generated);
  • DATE_START_2 - last value of the first hit generation time range (time till which the first hit could be generated);
  • DATE_END_1 - first value of the last hit generation time range (time from which the last hit could be generated);
  • DATE_END_2 - last value of the last hit generation time range (time till which the last hit could be generated);
  • URL_TO* - the first page of the session;
  • URL_TO_EXACT_MATCH - if "Y", the URL_TO must match exactly (strict match);
  • URL_TO_404 - indicates the error 404 occurred on the first page of the session (Y|N);
  • FIRST_SITE_ID* - the ID of the first hit site;
  • FIRST_SITE_ID_EXACT_MATCH - if "N", entry in the FIRST_SITE_ID is sufficient (loose match);
  • URL_LAST* - the last page of the session;
  • URL_LAST_EXACT_MATCH - if "Y", the URL_LAST must match exactly (strict match);
  • URL_LAST_404 - indicates the error 404 occurred on the last page of the session (Y|N);
  • LAST_SITE_ID* - the ID of the last hit site;
  • LAST_SITE_ID_EXACT_MATCH - if "N", entry in the LAST_SITE_ID is sufficient (loose match).
* - complex logic allowed.
is_filtered If this flag contains "true" on return, the resulting list is filtered.

Structure of the returned record

Array
(
    [ID] => the session ID
    [GUEST_ID] => the visitor ID
    [NEW_GUEST] => [Y|N] flag: new visitor
    [USER_ID] => the ID of a user under which the visitor
                 was last authorised
    [USER_AUTH] => [Y|N] flag: whether the visitor was authorised
                               during this session
    [C_EVENTS] => number of events occurred during this session
    [HITS] => number of hits occurred during this session
    [FAVORITES] => [Y|N] flag: the site was added to Favorites
    [STOP_LIST_ID] => the ID of the stop list record
                      for the visitor (if applicable)
    [COUNTRY_ID] => the visitor country ID
    [USER_AGENT] => the visitor UserAgent

    [URL_FROM] => the referring page of the first session hit

    [DATE_STAT] => date of the first hit
    [DATE_FIRST] => time of the first hit
    [URL_TO] => the first page of the session
    [URL_TO_404] => [Y|N] indicates the error 404 occurred
                    on the first page of the session
    [FIRST_HIT_ID] => the first hit ID
    [FIRST_SITE_ID] => the ID of the first hit site
    [IP_FIRST] => the visitor IP address during the first hit
                  (in the form XXX.XXX.XXX.XXX)
    [IP_FIRST_NUMBER] => the visitor IP address during the first hit
                         (numerical)

    [DATE_LAST] => date and time the last hit occurred
    [URL_LAST] => the last page of the session
    [URL_LAST_404] => [Y|N] indicates the error 404 occurred
                      on the last page of the session
    [LAST_HIT_ID] => the last hit ID
    [LAST_SITE_ID] => the ID of the last hit site
    [IP_LAST] => the visitor IP address during the last hit
                 (in the form XXX.XXX.XXX.XXX)
    [IP_LAST_NUMBER] => the visitor IP address during the first hit
                        (numerical)
    
    [ADV_ID] => the advertising campaign ID
    [ADV_BACK] => [Y|N] flag: direct hit (N)
                  or return (Y) under an advertising campaign
    [REFERER1] => the referer1 identifier of an advertising campaign
    [REFERER2] => the referer2 identifier of an advertising campaign
    [REFERER3] => the referer3 auxiliary parameter of an advertising campaign

    [SESSION_TIME] => time difference between the first and last hits (sec.)
    [PHPSESSID] => the PHP session identifier
)

See Also

Example



<?
// select all existing sessions of the visitor #1025
$arFilter = array(
    "GUEST_ID" => "1025"
    );

// obtain the list of records
$rs = CSession::GetList(
    ($by = "s_id"), 
    ($order = "desc"), 
    $arFilter, 
    $is_filtered
    );

// print all records
while ($ar = $rs->Fetch())
{
    echo "<pre>"; print_r($ar); echo "</pre>";    
}
?>