Consent Required
TrueNecessary
TrueStatistics
FalseMarketing
FalsePreferences
FalseThe Cookie Consent system provides GDPR-compliant cookie consent management with FodCookieBanner (with inline expandable settings), IFodConsentService integration, and full localization support (English, Romanian).
Display the current consent status and accepted categories.
Consent Required
TrueNecessary
TrueStatistics
FalseMarketing
FalsePreferences
FalseThe cookie banner is placed in MainLayout and automatically shows when consent is required. Click 'Show Banner' to trigger it by revoking consent.
<FodCookieBanner
Position="BannerPosition.Bottom"
PrivacyPolicyUrl="/privacy"
CookiePolicyUrl="/cookie-policy" />Use IFodConsentService to programmatically manage consent state.
Accept all categories
Accept necessary only
Custom consent
Revoke consent
@inject IFodConsentService ConsentService
// Accept all categories
ConsentService.AcceptAll();
// Accept only necessary cookies
ConsentService.AcceptNecessaryOnly();
// Custom consent selection
ConsentService.UpdateConsent(
ConsentCategory.Necessary | ConsentCategory.Statistics | ConsentCategory.Marketing
);
// Revoke all consent (triggers banner to show)
ConsentService.RevokeConsent();
// Check if category is accepted
bool isAccepted = ConsentService.Current.IsCategoryAccepted(ConsentCategory.Marketing);Subscribe to the OnConsentChanged event to react to consent state changes.
protected override void OnInitialized()
{
ConsentService.OnConsentChanged += HandleConsentChanged;
}
private void HandleConsentChanged(ConsentChangedEventArgs args)
{
// args.Reason: User, Initialization, Expiration, Revocation
// args.Current.AcceptedCategories: The new consent categories
InvokeAsync(StateHasChanged);
}
public void Dispose()
{
ConsentService.OnConsentChanged -= HandleConsentChanged;
}How to set up and use the Cookie Consent system in your application.
// Program.cs
builder.Services.AddFod(options =>
{
options.ConsentOptions.PrivacyPolicyUrl = "/privacy";
options.ConsentOptions.CookiePolicyUrl = "/cookie-policy";
options.ConsentOptions.ExpirationMonths = 12;
});builder.Services.AddFod(options =>
{
options.ConsentOptions.CookieName = "my_consent";
options.ConsentOptions.ExpirationMonths = 6;
options.ConsentOptions.PrivacyPolicyUrl = "/privacy";
options.ConsentOptions.CookiePolicyUrl = "/cookies";
options.ConsentOptions.EnableGoogleConsentMode = true;
options.ConsentOptions.EnableScriptBlocking = true;
options.ConsentOptions.ConsentVersion = 1;
});<FodCookieBanner
Position="BannerPosition.Bottom"
PrivacyPolicyUrl="/privacy"
CookiePolicyUrl="/cookie-policy" />FodCookieBanner is fully localized using IStringLocalizer. All text content uses resource files that can be extended for additional languages.
You can override any localized text using component parameters. Parameter values take precedence over localized strings.
<!-- Override localized text with custom values -->
<FodCookieBanner
AcceptAllText="Accept Cookies"
NecessaryOnlyText="Essential Only"
ManageCookiesText="Cookie Settings"
PrivacyPolicyText="View Privacy Policy"
CookiePolicyText="View Cookie Policy" />Cookie consent components provide WCAG 2.1 AA compliant accessibility features.
role="region" - Identifies the banner as a landmark regionaria-label - Provides accessible name for the banneraria-describedby - Links banner to its description textaria-expanded - Indicates expandable settings section statearia-controls - Links toggle button to settings contentFodCookieBanner and IFodConsentService API documentation.