Skip to content

Commit 4ec3d08

Browse files
Updated examples
1 parent bffbc4a commit 4ec3d08

5 files changed

Lines changed: 26 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ composer.phar
66
composr.lock
77
favicon.ico
88
php.ini
9-
.idea/
9+
.idea/
10+
.DS_Store

composer.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/flat-php/advanced.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
$api = new CrowdHandler\PublicClient('ace1f8062f2df869a5fb0cbd69f51c10d2821dd1e4519e110206eca9e3db86c8'); // your public key here.
1111
$ch = new CrowdHandler\GateKeeper($api);
1212
$ch->setSafetyNetSlug('sandbox'); // users will be directed to a known slug (must be one of yours) if API request or response fails
13-
$ch->setToken( isset($_SESSION['ch-id']) ? $_SESSION['ch-id'] : null );
1413
$ch->checkRequest();
1514
if(!$ch->result->promoted) {
1615
header('location:'.$ch->getRedirectUrl(), 302);

examples/flat-php/basic.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
$api = new CrowdHandler\PublicClient('ace1f8062f2df869a5fb0cbd69f51c10d2821dd1e4519e110206eca9e3db86c8'); // your public key here.
66
$ch = new CrowdHandler\GateKeeper($api);
77
$ch->checkRequest();
8-
$ch->setCookie();
98
$ch->redirectIfNotPromoted();
109

1110
?>

examples/slim-framework-psr/web/index.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
// We pass Slim's PSR7 request instead of having GateKeeper corale info from CGI variables
1111
$ch = new CrowdHandler\GateKeeper($api, $request);
1212
$ch->checkRequest();
13-
// We use Slim to set the cookie, not the method inside GateKeeper
14-
$cookies = new Slim\Http\Cookies();
15-
$cookies->set('ch-id', ['value' => $ch->result->token, 'path'=>'/']);
13+
1614
if($ch->result->promoted) {
1715
// Here you would build your response as normal. We're just rendering the CrowdHandler Result
1816
$response->getBody()->write($ch->result);
1917
// Now log the performance, we're about to dispatch the response
2018
$ch->recordPerformance(200);
21-
return $response->withHeader('Set-Cookie', $cookies->toHeaders());
19+
return $response;
2220
} else {
23-
return $response->withHeader('Set-Cookie', $cookies->toHeaders())->withRedirect($ch->getRedirectUrl(), 302);
21+
return $response->withRedirect($ch->getRedirectUrl(), 302);
2422
}
2523
});
2624
$app->run();

0 commit comments

Comments
 (0)