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>
|
||||
function closeIt() {
|
||||
document.getElementById("gdpr").style.display = "none";
|
||||
document.cookie = "banner=seen; max-age=600;";
|
||||
document.cookie = "banner=seen; <%= $sessionLife %>;";
|
||||
}
|
||||
|
||||
function playIt() {
|
||||
|
|
|
@ -17,14 +17,18 @@ plugin CGI => ['/cgi-bin/whoami.cgi' => './cgi-bin/whoami.cgi' ];
|
|||
# Handle the session
|
||||
under sub {
|
||||
my ($c) = @_;
|
||||
my $sessionLife = 604800;
|
||||
|
||||
if ($c->cookie('banner') eq 'seen') {
|
||||
# Set session for a week
|
||||
$c->session(expiration => 604800)->{banner} //= 'seen';
|
||||
$c->session(expiration => $sessionLife, banner => 'seen');
|
||||
# Kill plain-text cookie
|
||||
$c->cookie(banner => 'seen', {expires => 1});
|
||||
}
|
||||
|
||||
# Pass in the expiration for plain-text cookie
|
||||
$c->stash(sessionLife => $sessionLife);
|
||||
|
||||
1;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue