Make the visitor counter increment when a new session is created
This commit is contained in:
parent
3532310738
commit
27ec34b208
|
@ -40,7 +40,13 @@ under sub ($c) {
|
||||||
# https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network
|
# https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network
|
||||||
$c->res->headers->header('Permissions-Policy', 'interest-cohort=()');
|
$c->res->headers->header('Permissions-Policy', 'interest-cohort=()');
|
||||||
|
|
||||||
$c->session(expiration => 86400);
|
unless ($c->session('counted')) {
|
||||||
|
$c->counter->increment_visitor_count();
|
||||||
|
$c->session(
|
||||||
|
expiration => 86400,
|
||||||
|
counted => 'true'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$c->stash(status => 403) if $c->flash('error');
|
$c->stash(status => 403) if $c->flash('error');
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ sub get_visitor_count($self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub increment_visitor_count($self) {
|
sub increment_visitor_count($self) {
|
||||||
$self->pg->db->query(<<~'END_SQL')->text()
|
$self->pg->db->query(<<~'END_SQL')
|
||||||
UPDATE counters
|
UPDATE counters
|
||||||
SET counter_value = counter_value + 1
|
SET counter_value = counter_value + 1
|
||||||
WHERE counter_name = 'visitor';
|
WHERE counter_name = 'visitor';
|
||||||
|
|
Loading…
Reference in a new issue