Skip to content

Commit

Permalink
Removed example link and added example file
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankruijter committed Dec 27, 2019
1 parent f71191a commit 696fec7
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 11 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ public function setCookie(string $scope, string $name, string $value = "", int $
public function getCookie(string $scope, string $name, string $path = "", string $domain = "", bool $secure = false, bool $httponly = false);
```

## Demo
A live example is available here: [https://gdpr-cookie-example.jyxon.com/](https://gdpr-cookie-example.jyxon.com/).

## Feedback
We like to get some feedback on this package. You can do so by creating an issue on GitHub.

Expand Down
1 change: 1 addition & 0 deletions example/assets/css
1 change: 1 addition & 0 deletions example/assets/js
88 changes: 88 additions & 0 deletions example/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
require_once('../vendor/autoload.php');

use Jyxon\GdprCookieCompliance\Cookie\Settings;
use Jyxon\GdprCookieCompliance\Cookie\Manager;

$settings = new Settings();
$manager = new Manager($settings);

$configuration = file_get_contents('../src/Config/config.json');

if (isset($_GET['set_cookie']) && in_array($_GET['set_cookie'], ['analytical', 'functional'])) {
$manager->setCookie($_GET['set_cookie'], $_GET['set_cookie'] . '_cookie', 'Cookie set!', time() + 3600, '/');
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GDPR cookie compliance example</title>
<link rel="stylesheet" type="text/css" href="assets/css/gdpr_cookie_bar.css">
<style>
a, button {
display: inline-block;
padding: 3px 5px;
border: 1px solid #159615;
background: #41b741;
color: #fdfdfd;
text-decoration: none;
font-size: 14px;
cursor: pointer;
}

pre {
background-color: lightgrey;
border: 1px solid darkgrey;
padding: 5px;
display: block;
}
</style>
</head>
<body>
<h4>Configuration:</h4>
<pre><?= $configuration ?></pre>
<hr>

<h4>Cookies set:</h4>
<pre><?= json_encode($_COOKIE, JSON_PRETTY_PRINT) ?></pre>
<hr>

<h4>Analytical cookie</h4>
<pre><?= $manager->getCookie('analytical', 'analytical_cookie') ?></pre>

<h4>Functional cookie</h4>
<pre><?= $manager->getCookie('functional', 'functional_cookie') ?></pre>
<hr>
<a href="?set_cookie=analytical">Set analytical cookie server side</a>
<a href="?set_cookie=functional">Set functional cookie server side</a>
<br><br>
<script src="assets/js/cookie_tool.js"></script>
<script src="assets/js/gdpr_compliance.js"></script>
<script src="assets/js/gdpr_cookie.js"></script>
<script>
var cookieTool = cookie_tool();
var configuration = <?= $configuration ?>;
var gdprCompliance = gdpr_compliance(configuration, cookieTool);
gdprCompliance.init();
var gdprCookie = gdpr_cookie(gdprCompliance, cookieTool);
var cookieDate = new Date();
cookieDate.setTime(cookieDate.getTime() + (24*60*60*1000))
</script>
<button onclick="gdprCookie.setCookie(
'analytical',
'analytical_cookie',
'Cookie set through the client!',
cookieDate.toUTCString()
)" type="button">Set analytical cookie client side</button>
<button onclick="gdprCookie.setCookie(
'functional',
'functional_cookie',
'Cookie set through the client!',
cookieDate.toUTCString()
)" type="button">Set functional cookie client side</button>
<p><b>Please note:</b> Don't forget to refresh the page after setting cookies or expecting result.</p>
</body>
</html>
6 changes: 0 additions & 6 deletions src/Cookie/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public function canSet(string $scope): bool
* @param boolean $httponly
*
* @return bool
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function setCookie(
string $scope,
Expand Down Expand Up @@ -87,9 +84,6 @@ public function setCookie(
* @param boolean $httponly
*
* @return mixed
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function getCookie(
string $scope,
Expand Down
2 changes: 0 additions & 2 deletions src/Cookie/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public function getAllowedCookies(): array
* Sets the local variable of $allowedCookies with the contents of the "gdpr_cookie" contents.
*
* @return void
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
private function setAllowedCookies()
{
Expand Down

0 comments on commit 696fec7

Please sign in to comment.