Cookie / Consent Banner Plugin
The Cookie Consent plugin provides a configurable GDPR-friendly cookie consent banner for your LusterCMS website.
Overview
This plugin allows you to:
- Display a consent banner on your public website
- Customize banner text, colors, and position
- Track visitor consent preferences
- Conditionally load analytics based on consent
Installation
- Go to Plugins in your admin panel
- Find "Cookie / Consent Banner" in the marketplace
- Click Install
- Navigate to Plugins → Cookie Consent to configure
Configuration
Content Settings
| Setting | Description | Default |
|---|---|---|
| Title | Optional banner title | "Cookie Settings" |
| Description | Main consent message | Standard GDPR-friendly text |
| Accept All Button | Label for accepting all cookies | "Accept all" |
| Necessary Only Button | Label for essential cookies only | "Only necessary" |
| Learn More Link | Link text for privacy policy | "Learn more" |
| Privacy URL | Path to your privacy policy | "/privacy" |
Appearance Settings
| Setting | Description | Default |
|---|---|---|
| Position | Banner position on screen | Bottom (full width) |
| Background Color | Banner background | #1a1a2e (dark blue) |
| Text Color | Banner text color | #ffffff (white) |
| Accent Color | Button and link color | #7367F0 (purple) |
| Button Style | Primary, Secondary, or Outline | Primary |
Positions
- Bottom - Full-width bar at the bottom of the screen
- Bottom Left - Compact card in the bottom-left corner
- Bottom Right - Compact card in the bottom-right corner
- Full Width - Same as Bottom, spans entire width
Consent Storage
The plugin stores the user's consent choice in localStorage:
// Key: luster_cookie_consent
// Values: "all" | "necessary"
localStorage.getItem("luster_cookie_consent");
Developer API
The plugin provides utility functions for checking consent:
hasFullConsent()
Returns true if the user has accepted all cookies.
import { hasFullConsent } from '@/plugins/cookie-consent/consent-utils';
if (hasFullConsent()) {
// Load Google Analytics, third-party widgets, etc.
initAnalytics();
}
getConsentLevel()
Returns the current consent level: "all", "necessary", or null (no decision yet).
import { getConsentLevel } from '@/plugins/cookie-consent/consent-utils';
const level = getConsentLevel();
if (level === "all") {
// Full consent given
} else if (level === "necessary") {
// Only essential cookies allowed
} else {
// No decision yet - show banner
}
hasConsentDecision()
Returns true if the user has made any consent decision.
import { hasConsentDecision } from '@/plugins/cookie-consent/consent-utils';
if (!hasConsentDecision()) {
// Show consent banner
}
Consent Change Event
Listen for consent changes:
window.addEventListener("luster-consent-change", (event) => {
const { level } = event.detail; // "all" or "necessary"
if (level === "all") {
loadAnalytics();
}
});
API Endpoints
Get Settings (Admin)
GET /api/plugins/cookie-consent/settings
Authorization: Bearer <token>
Update Settings (Admin)
PUT /api/plugins/cookie-consent/settings
Authorization: Bearer <token>
Content-Type: application/json
{
"enabled": true,
"descriptionText": "Custom message...",
"position": "bottom-right"
}
Get Public Settings (Frontend)
GET /api/plugins/cookie-consent/public
Returns settings for rendering the banner on the public website. No authentication required.
Integration with Themes
The banner component automatically appears on your public website when the plugin is enabled. To manually integrate:
import CookieConsentBanner from '@/plugins/cookie-consent/frontend/CookieConsentBanner';
function SiteLayout({ children }) {
const [config, setConfig] = useState(null);
useEffect(() => {
fetch('/api/plugins/cookie-consent/public')
.then(res => res.json())
.then(setConfig);
}, []);
return (
<>
{children}
<CookieConsentBanner config={config} />
</>
);
}
Best Practices
- Link to Privacy Policy - Always provide a link to your full privacy policy
- Clear Language - Use simple, understandable text
- Respect Choice - Actually disable non-essential cookies when user chooses "necessary only"
- Test on Mobile - Ensure the banner is usable on small screens
Legal Disclaimer
This plugin is a technical tool to help display consent banners. It does not constitute legal advice. You are responsible for:
- Ensuring your cookie usage complies with applicable laws
- Writing accurate consent text
- Actually implementing consent-based cookie control
- Consulting with legal counsel for compliance requirements