From 80b2acb79a9b20d987cf1b0e992aa01c0acee766 Mon Sep 17 00:00:00 2001 From: swag Date: Mon, 4 Apr 2022 17:22:23 -0400 Subject: [PATCH] expires vs expiration It appears I have misunderstood the difference between `expires => time() + 3600` and `expiration => 3600` as I thought `expires` would just set the expiration one time and not update for subsequent requests. Per this discussion thread, that does not appear to be correct: https://github.com/mojolicious/mojo/discussions/1833 Thus I felt it best to just set the expiry period to 30 min and allow that to reset on subsequent requests rather than reinvent the wheel --- guestbook-ng.pl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/guestbook-ng.pl b/guestbook-ng.pl index bde507f..51dc9c6 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -43,14 +43,10 @@ under sub ($c) { unless ($c->session('counted')) { $c->counter->increment_visitor_count(); $c->session( - expires => time() + 3600, - counted => 1 + expiration => 1800, + counted => 1 ); } - # Delete this since I was supposed to be using 'expires' instead - # of 'expiration'; the difference is outlined here: - # https://docs.mojolicious.org/Mojolicious/Controller#session - delete $c->session->{'expiration'} if $c->session('expiration'); $c->stash(status => 403) if $c->flash('error');