Buyer Age Verification Setup (18+) on 1C-Bitrix
Online stores selling alcohol, tobacco, medicines, and other age-restricted goods are required to verify the buyer's age. Bitrix does not provide a ready-made verification mechanism — it must be built from scratch, choosing the verification level from a simple modal window to full identification via government services.
Age Verification Levels
Level 1 — Declaration. The customer self-confirms "I am 18 years of age or older." Technically, this is a modal window on the first visit to the site with "Yes" and "No" buttons. The result is stored in the cookie age_verified=1 for 30 days. Legally this is weak protection, but it is sufficient for certain product categories.
Level 2 — Date of Birth. The user enters their date of birth. This is verified mathematically: (today - birthdate) >= 18 years. The result is also stored in a cookie or session. Trivially easy to bypass, but it places legal responsibility on the buyer.
Level 3 — Document Verification. Integration with ESIA (Government Services portal) or services such as IDEX or Kontur.Check. Age is confirmed against passport data. The most reliable option; requires a separate integration.
Implementation in Bitrix (Levels 1–2)
The OnPageStart event handler in init.php checks for the cookie and, if necessary, adds the modal window to the output queue:
AddEventHandler('main', 'OnPageStart', function() {
global $APPLICATION;
if (!isset($_COOKIE['age_verified'])) {
$APPLICATION->AddHeadScript('/local/js/age-verify.js');
$APPLICATION->SetAdditionalCSS('/local/css/age-verify.css');
}
});
The JavaScript component displays a modal window that blocks interaction with the page until confirmation. On confirmation:
document.cookie = 'age_verified=1; max-age=' + (86400 * 30) + '; path=/; SameSite=Lax';
On refusal — redirect to a stub page or to an external URL.
Category-Level Restriction
Verification may be required not for the entire site but only for specific catalog sections. A property UF_AGE_RESTRICTED (checkbox) is created in the sections infoblock. The handler checks not just the presence of the cookie but also whether the current page belongs to a restricted category.
For section pages and product detail pages in the bitrix:catalog component, the OnBeforeProlog handler checks the property of the current section:
$sectionId = $arParams['SECTION_ID'];
$section = CIBlockSection::GetByID($sectionId)->Fetch();
if ($section['UF_AGE_RESTRICTED'] && !isset($_COOKIE['age_verified'])) {
LocalRedirect('/age-check/?back=' . urlencode($REQUEST_URI));
}
Verification When Adding to Cart
One important checkpoint is adding an age-restricted product to the cart. Even if the customer completed verification on entry, the cookie may have expired. The OnSaleBasketItemAdd event handler checks for a valid confirmation:
AddEventHandler('sale', 'OnSaleBasketItemAdd', function(&$arFields) {
$productId = $arFields['PRODUCT_ID'];
if (isAgeRestrictedProduct($productId) && !isAgeVerified()) {
return new CDBResult(false, 'Please confirm your age to add this product');
}
});
Storing Verification Status for Authorized Users
For authorized users, the verification result can be stored in their profile — a UF field UF_AGE_VERIFIED (type "Yes/No") and UF_BIRTH_DATE (date). On the next login, the cookie is set automatically without requiring verification again.
What Is Included in the Setup
- Developing the verification modal with the chosen verification level
-
OnPageStarthandler with cookie check - Setting up the
UF_AGE_RESTRICTEDproperty for catalog sections - Restricting access to categories and product detail pages without verification
- Blocking the addition of age-restricted products to the cart
- Saving verification status in the authorized user's profile

