Bitrix Site Manager

Page execution order

The below table outlines execution order of the page whose structure conforms to the rules described in the Page structure section.

NoOperationDefinable constants and variables Remarks
1. Prologue service section
1.1 Includes
  The included file is to contain debugging constants, access permissions and definitions of variables used to connect to the database.
1.2 Connects to the database $DB In case of an error, the file 
is included.
1.3 Includes
  The file included may contain operations which are to be executed right after the connection to the database is established.
all the classes and functions of the Kernel module are defined.
If the constant SITE_ID with the site ID is defined, the site is not determined by the current folder and domain; all other constants are determined using the site SITE_ID.
1.5 Includes
  May initialise event handlers and include additional functions common for all sites.
1.6 Includes
/bitrix/php_interface/site ID/init.php
  Contains parameters and function definitions for the specific site.
1.7 Checks agents   Variables $USER, $_SESSION as well as those determined below cannot be used in agents.
1.8 The OnPageStart event is fired    
1.9 Opens session All the session variables $_SESSION.  
1.10 Defines user, authorizes user, completes session, registers (depending on parameters in request) $USER  
1.11 Determines the current site template SITE_TEMPLATE_ID  
1.12 The OnBeforeProlog event is fired    
1.13 Checks access permissions of the first level   If the user has not enough permissions, the authorization form is displayed and the page completes the execution.
1.14 Starts buffered output   After the buffered output is started, you can emit any visual data. The output may precede or follow setting cookies.
1.15 OnProlog Event
2. Prologue visual section
2.1 Includes
/bitrix/templates/site template ID/header.php
3. Page body
4. Epilogue visual section
4.1 Includes
/bitrix/templates/site template ID/footer.php
4.2 Calls the function CMain::ShowSpreadCookieHTML   This function displays a set of invisible IFRAME's used in user transfer technology.
5. Epilogue service section
5.1 The OnEpilog event is fired    
5.2 Completes the page buffering   Completes and flushes the buffer initialised in 1.14
5.3 Sends e-mails   For more information about e-mail messages, you may read in the Mail system section.
5.4 The OnAfterEpilog event is fired    
5.5 Completes the database connection Variable $DB is no more available  

See Also