Refine the new cookie/session behavior
Session is now a variable; applies to plain-text and session cookies (controller and passed throught to layout via stash())
This commit is contained in:
parent
392f55a791
commit
13924d7f61
|
@ -25,7 +25,7 @@
|
||||||
<script>
|
<script>
|
||||||
function closeIt() {
|
function closeIt() {
|
||||||
document.getElementById("gdpr").style.display = "none";
|
document.getElementById("gdpr").style.display = "none";
|
||||||
document.cookie = "banner=seen; max-age=600;";
|
document.cookie = "banner=seen; <%= $sessionLife %>;";
|
||||||
}
|
}
|
||||||
|
|
||||||
function playIt() {
|
function playIt() {
|
||||||
|
|
|
@ -16,15 +16,19 @@ plugin CGI => ['/cgi-bin/whoami.cgi' => './cgi-bin/whoami.cgi' ];
|
||||||
|
|
||||||
# Handle the session
|
# Handle the session
|
||||||
under sub {
|
under sub {
|
||||||
my ($c) = @_;
|
my ($c) = @_;
|
||||||
|
my $sessionLife = 604800;
|
||||||
|
|
||||||
if ($c->cookie('banner') eq 'seen') {
|
if ($c->cookie('banner') eq 'seen') {
|
||||||
# Set session for a week
|
# Set session for a week
|
||||||
$c->session(expiration => 604800)->{banner} //= 'seen';
|
$c->session(expiration => $sessionLife, banner => 'seen');
|
||||||
# Kill plain-text cookie
|
# Kill plain-text cookie
|
||||||
$c->cookie(banner => 'seen', {expires => 1});
|
$c->cookie(banner => 'seen', {expires => 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Pass in the expiration for plain-text cookie
|
||||||
|
$c->stash(sessionLife => $sessionLife);
|
||||||
|
|
||||||
1;
|
1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue