nickdekruijk/cookiewall

适用于欧盟法律的简单cookie接受弹窗

dev-master 2022-04-12 09:19 UTC

This package is auto-updated.

Last update: 2024-09-12 14:43:13 UTC


README

根据欧盟法律,访问者应同意所有跟踪cookie/像素/代码。此软件包将为您的Laravel应用程序添加一个简单的“接受cookie”弹出窗口。

安装

要安装包,请使用 composer require nickdekruijk/cookiewall

如果您想自定义配置,请发布配置文件

php artisan vendor:publish --provider=NickDeKruijk\\Cookiewall\\CookiewallServiceProvider

对于低于5.5版本的Laravel,请将服务提供者添加到 config/app.php 中的 'providers' 数组

NickDeKruijk\Cookiewall\CookiewallServiceProvider::class,

前端

将以下代码添加到您想要显示弹出窗口的每个视图/页面中

@include('cookiewall::show')

并且用 cookiewallAccept() 辅助函数包裹放置跟踪cookie/像素/代码的任何代码,例如

@if (cookiewallAccept())
// Your tracking code here
@endif

并根据您的喜好样式化弹出窗口,例如

.cookiewall-container {position:fixed;bottom:0;left:0;right:0;background-color:red;text-align:center;padding:50px;z-index:9999;color:#fff}
.cookiewall-button {display:inline-block;padding:10px 20px;border:2px solid #fff;border-radius:5px;text-decoration:none;color:inherit;margin:10px}
.cookiewall-button:hover {background-color:rgba(255,255,255,0.5)}
.cookiewall-button-accept {background-color:#fff;color:red}
.cookiewall-button-accept:hover {background-color:rgba(255,255,255,0.8)}